Nov 21

Wordpress Cache Friendly

posted in Caching, Wordpress on 11/21/07 at 05:11 PM

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.

Technorati Tags: , , , ,

Thanks for taking the time to read this post. If you're new here and liked what you read you may want to subscribe to my RSS feed or get new posts via Email.

I also love to get feedback. Feel free to comment and add to the conversation or start it, or just say hi! Thanks for stopping by and I hope to see you again soon.

Leave a Reply

By submitting a comment here you grant this site a perpetual license to reproduce your words and name/web site in attribution. I reserve the right to delete any comment for any reason with and will aggressively smite spam, flames and unsavory behavior.