Neil Turner's Blog

Blogging about technology and randomness since 2002

How to: Boost WordPress performance with W3 Total Cache and APC

Stone carving

Earlier this month I posted about my attempts at boosting traffic to this blog using various technical interventions, and so far, when combined with a couple of popular posts (my guide to improving iPhone battery life and cloud storage service comparisons in particular) have seen traffic go up around 20% on average.

A big change was a new caching plugin. As I previously mentioned I used to use WP Quick Cache, which is a good, basic plugin that doesn’t need much configuration, but I’ve had better results with W3 Total Cache. It takes more work to get running optimally though.

If you have shell access to your server, you can combine W3 Total Cache with APC – the Accelerated PHP Cache – to further boost performance. Getting these to work together has not just boosted the performance of the front-facing site, but also the WordPress CMS dashboard as well, so it’s well worth looking into.

Firstly, you will need to install APC, as it’s not usually installed along with PHP. Log into your server using SSH to get a shell prompt, and type in pecl install apc – you may need to do ‘sudo’ if you’re not root. This will install the APC package from pecl.

If you get an error that pecl isn’t a recognised command, instead try ‘sudo apt-get install php-apc php-pear‘. That worked for me.

Next, you need to install W3 Total Cache. It’s not the easiest plugin to install as you’ll need to make a couple of folders writeable and then modify your .htaccess file to enable it, but the instructions are quite clear.

You’ll now need to configure W3 Total Cache to use APC. I’ve taken hints from this guide by Chris Gilligan, and whilst it’s worth reading all of his blog posts on the subject, we’ll skip to the section where he tells you which modules to enable and which ones to use APC on. APC is just one of a number of ways that you can cache data, and it’s not always appropriate. For the Page Cache, don’t use APC – use the Enhanced Disk cache if possible. Similarly don’t use APC for the Minify Cache – in my own testing, enabling APC for Minify completely broke it.

Where you do want to enable APC is for the Object Cache and Database Cache. These are all on the General Settings page – make sure each of the modules are enabled and then save your settings. If you’ve previously used W3 Total Cache with different settings, you should also clear all of the caches after this.

If your experience was like mine, this should result in a shot in the arm for your site’s performance.

Comments are closed.