Like most CMS softwares, Wordpress is not blazing fast out of the box. That’s mainly due to the nature of CMS systems: they generate pages dynamically. To do so, they rely heavily on their database backend. That’s far from being fast compared to serving up static HTML content. Fear not though, there are ways to improve Wordpress’ speed by a lot. It’s after all used by many large web properties.

Being currently unemployed, I’m not getting my normal dose of nerdy stuff I usually get. Am I going through techie withdrawal? I thought my blog was feeling a bit sluggish, so I decided to see what I could do about that. My goal was to score A in YSlow and over 95 in PageSpeed.

Varnish

This daemon is by far one my favorite tool. It’s blazing fast. In tests I’ve done in the past, I was able to pack over 15000 requests/second on one virtual machine. Kristian Lyngstol even managed to push Varnish pretty far at 275000 requests/second on badass hardware. Keep in mind though, that was in a lab. And it always work better in labs.

In a previous post, I was explaining the configuration I use to achieve good caching of Wordpress. Basically, my configuration increases browser caching of static objects like CSS, JavaScripts and images. But even with that, the site was not loading optimally.

NOTE: My config is very aggressive, it removes pretty much every cookies. The only issue I’ve seen so far is that I have to login every time I want to post. Might be inconvenient for people who save their credentials. But that’s not too good security wise. Maybe one day I’ll fix that.

To allow the W3 Total Cache plugin to purge objects in Varnish, you need to add the following few lines of config under /etc/varnish/default.vcl.

First, we must add an ACL to allow the local web server to purge the cache:

acl purge {
  "127.0.0.1";
}

Next, we need to tell Varnish what to do with PURGE requests:

sub vcl_recv {
  purge("req.url == " req.url " && req.http.host == " req.http.host);
  error 200 "Purged.";
}

Memcache

Another incredible tool to use in the web world. It’s often used to cache results from SQL queries, to speed things up. I use it in conjunction with the W3 Total Cache plugin to cache pages, queries and objects. This gave a good boost to load time. As it’s much faster to fetch something out of memcache instead of running a SQL query.

I use the following configuration:

  • 128 MB of RAM for caching
  • allowed 1024 connections

Plugins

I was writing yesterday about the plugin WP Minify. Well, it’s still a good plugin. But W3 Total Cache is much more complete. Here’s its features:

  • CSS/JavaScripts minifying, without modification of your theme.
  • Support for object URL rewriting to use with a CDN. Again not modification of your theme required.
  • Supports caching of pages, objects and databases queries into memcache.
  • Redirection of mobile User-Agent to a different site.
  • Purging of objects in Varnish.
  • Configuration of expires, cache-control, pragma, etags and compression.
  • Priming your cache

Personally, I remove some of the headers with Varnish and set expires through my web server. But the minifying and caching in memcache is what I was looking for. It all comes with a nice configuration panel that’s added in the admin pages.

Testing

To ensure a proper test, clear your browser’s cache. Or Ctrl-F5 your page. Then access your site. Fire up either YSlow orPageSpeed. You should now have some decent load times.

CDN

Also known as content delivery network. By leveraging one of them, you could have your static objects sent from asub domainsuch as static.domain.tld. It would improve load times ever more, as it would use the browser’s parallel downloads. That’s very useful to use on high traffic websites. Mine doesn’t require that, but it’s an option worth investigating if you do.

VMware Tools RPM version for RHEL guests

Like most CMS softwares, Wordpress is not blazing fast out of the box. That’s mainly due to the nature of CMS systems: they generate page...… Continue reading

Boxee vs Roku review

Published on January 12, 2014

Immutable directory on Linux

Published on December 12, 2013