Skip to content

December 9, 2009

6

How to Optimize WordPress, Part 2

by Dan

My last post on how to optimize WordPress covered some general optimization techniques to speed up a website. Reducing HTTP requests, removing wasteful plugins and decreasing file sizes helped quite a bit. Now it’s time to try out page caching.

If you remember, the five things that normally occur for each page are:

  1. Initialize PHP
  2. Query the database
  3. Create the page
  4. Send the page
  5. Send additional files

Page caching plugins, like Hyper Cache and W3 Total Cache, eliminate steps two and three, except when creating a page the first time. WP Super Cache also cuts out step one.

All of the plugins were fairly easy to install. And I discovered during my tests that WP Super Cache, at least at Nearly Free Speech.NET, works just fine with safe mode on.

This graph shows the time it took to load my home page with each of the caching plugins enabled. I have circled the point where I first turned on page caching.

Graph showing response times with various caching plugs

Hyper Cache and WP Super Cache both performed well. W3 Total Cache seemed to struggle. It does more than page caching, like reformatting files to save space, but clearly slowed things down.

WP Super Cache has a few advantages over Hyper Cache:

  1. It supports browser caching better
  2. It doesn’t need to load PHP
  3. It checks for security problems and suggests fixes

So I am now a happy WP Super Cache user.

UPDATE Dec 2009:

After a few days, I started having issues with WP Super Cache and switched back to Hyper Cache. You can see how the irregularities went away. I’ve been using Hyper Cache for almost a week now, and things have remained stable.

Graph of WP Super Cache irregularities that were solved by changing back to Hyper Cache

After being contacted by the author of the W3 Total Cache plugin, I’ve agreed to give it another try. I turned off all the settings except for “disk enhanced” page caching. I’ll update the article again in a few days.

UPDATE Jan 2010:

After looking into things a bit more, my results are still showing Hyper Cache to be faster than W3 Total Cache. However, when I test using the curl command line tool from home, it seems that both plugins are about the same speed. My web hosting company uses a network-level reverse proxy and a few other caching tricks that eliminate the need for some of the features provided by these types of plugins. I’m not sure what’s going on here, but will be sticking with Hyper Cache for now since it appears to work better with my particular situation.

I do like that W3 Total Cache handles page compression properly. I could not get page compression to work with Hyper Cache and had to turn it off. I’d recommend you try all three plugins and measure which works best for you.

UPDATE Apr 2010:

I’ve been having some troubles with Hyper Cache recently. Page redirects were working properly in Firefox, but not in Safari. I tried a new caching plugin I hadn’t heard of before: Quick Cache. Redirects are now working in both browsers. After a week of using Quick Cache, it’s performance is very good. I’ve decided to stick with it.

6 Comments
  1. Frederick Townes
    Dec 24 2009

    Hi Daniel, thanks for including W3 Total Cache here. Would you mind updating the post to show the performance of W3 Total Cache with the page cache in disk enhanced mode? In that case you should see improved performance even over WP Super Cache even without database, minify or CDN functionality.

    Meanwhile if you do use minify and CDN (even self-hosted mode) you will be able to get most sites down to ~1.5-2s load time.

    Use the including .htaccess file for additional optimizations to improve your second page load performance.

    Thanks!

  2. Dec 24 2009

    I’d be happy to try it again. WP Super Cache has been having trouble recently, and I need to update the article anyway. Right now, I’ve switched back to Hyper Cache.

    I thought I was using disk enhanced mode for page caching — my web host doesn’t support the other types. Is there anything special I have to do? I’ll play with it more and post an update.

    Thanks for commenting.

  3. Frederick Townes
    Dec 24 2009

    Once disk enhanced is selected, look for any configuration notifications. Your .htaccess file needs to be updated, it will be done automatically if possible – that’s about it.

  4. Dec 28 2009

    Alright, I’ve got W3 Total Cache going again with disk enhanced mode. I’ll update the article again in a few days.

  5. Frederick Townes
    Jan 1 2010

    I just noticed that you have a rejected cookie which means that cache files are not going to be built (for post pages, the home page seems fine), which is exactly why your previous test (without enhanced mode) didn’t show a 50x-100x improvement over stock WordPress as it should have.

    Anyway, either a plugin is adding some cookies and breaking caching or you’ve specified that some cookies be rejected, which makes caching impossible.

    You can turn on debug mode in general settings so that more details about the caches you have enabled will appear in the front end HTML source. It also doesn’t appear that at least gzip compression is used – you’ll want to enable that.

  6. Jan 2 2010

    I had specifically turned compression off in case that was the problem. It looks like it isn’t, so I just turned it back on (using gzip).

    I’m not sure why a cookie would be causing an issue, but I’ll turn on debug mode to see if I can figure it out. Thanks for helping.

Comments are closed.