post

WordPress Cache Friendly

Sara Smith Interviewd Matt Mullenweg who you might know from WordPress. When I was working for 451 Press we were getting so much traffic that the servers couldn’t handle the load. WordPress, like any database driven site, can put quite a strain on a server. The majority of that being from mysql queries. The bad part of these kinds of site is that the pages rarely update. Pages like the front page update a few times a day, as do the category pages, but they don’t change that often. Actual posts and pages only update whenever an author edits them, which is not that often. Part of the http header response is whether or not a page can or should be cached. WordPress specifically tells the browser NOT to cache any pages generated by WP. Squid, setup as a revers proxy or caching server can let you cache a tremendous amount of pages with very little overhead relieving the load on your web server.

The problem is Squid obeys WordPress’ request to “not cache” those pages. The end result is that Squid will cache images, css, etc. but not the pages themselves. While this is a still a big improvement as static files get served from cache freeing up your web server to churn out more WordPress pages it could still be better.

One thing we did to help reduce the amount of mysql queries was use WP-Cache. Matt mentions in the interview that WordPress 2.4, which is due out pretty soon, will have the new version of WP-Cache built into the core. It’ll be disabled by default but you’ll be able to turn it on if you like. This is a big step forward in making WP more cache friendly. Add this to Squid with a dash of memcached and opcode caching and you could serve many, many, many times more pages than you were able to previously. This is the magic formula to surviving a Digg or slashdot or just a very popular site that gets lots of traffic. You might first be inclined to setup several web servers and do some load balancing or something like that but caching is cheaper and pretty easy to setup. If your site is still getting more traffic than your cache can handle then you can load balance your cache servers!

I’m just happy to see WordPress addressing something like this. As more sites use WP and become popular they are going to need this. It’s no longer just a need of large blog networks.

[tags]Wordpress, 2.4, Cache, WP-Cache, Squid[/tags]

About Chrispian

My name is Chrispian and I have to thank my parents for the forward thinking that ensured the .com would be available to me when the time came. I'm a self employed web developer and have been working in the computer / internet field for almost 14 years now

Add to the Conversation