Arne Brachhold

4+1 Ways To Speed Up WordPress With Caching

Filed under: Wordpress — arne on February 16, 2007

If you are suddenly receiving a lot of request within a short period of time because you’ve been linked by a large site like Digg or Slashdot, your hosting solution might not be able to handle the load.

This article should help your to prepare your WordPress blog for such a case or if you’re just using a slow webhost and want to improve the general performance.

Note that your room for maneuver is limited in most shared-hosting environments, so you won’t be able to implement all possible options with a $2.95 hosting account.

On the whole there are two areas where we can try to save processing time by caching frequently loaded data. The first one is the server system like the web- and database-server software, the second one is the application (WordPress) itself.

Figure of Caching Parts

MySQL Query Cache

Since WordPress uses MySQL, almost every page load results in various MySQL queries for logins, post content, categories and so on. It is very likely that this data didn’t change since the last request so we begin with enabling the cache within the MySQL server. Basically, all you need to to is to activate it in the my.cnf (or my.ini) MySQL configuration file with setting the query-cache-type variable to 1. The query-cache-size variable is the size of the query cache in MB, for example 20M. To change the MySQL configuration file, you’ll probably need root access which won’t be available on shared hosts. More info about query cache is available on and the MySQL Performance blog.

PHP Compiler Cache

WordPress is a PHP application so every request results in a call from the webserver (like Apache) to the PHP interpreter. This program reads the script files and compiles them into opcode which can be executed. This process may need some time, depending on the size of your script. A PHP Compiler cache saves the script in the compiled state in the memory which allows the PHP engine to execute it directly without compiling again which makes the execution about three times faster. Wide known PHP compiler caches are APC and eAccelerator. Please refer to their websites on how to install them, you will also need root access for that.

WordPress Internal Caching

In case of a slow database server, it might be a good idea to store frequently used data in a serialized form on disk. WordPress has an integrated disk-cache which stores rarely changing data like categories and users in a special folder. Note that this cache is not recommended if the disk is slow or your host (like DreamHost) set up a NFS based storage solution which would request the cached data from a remote storage server. To enable WordPress’s internal caching, uncomment or add this to your wp-config.php: define( ‘ENABLE_CACHE’, true ); and make sure that the wp-content/cache folder is writable!

Static Pages

If all the other caching methods are not enough or you can’t apply them, there is a last solution: Caching the complete generated pages. This can be done via an excellent plugin called WP-Cache. The plugin will cache the whole generated page on the disk and skip the complete WordPress execution on further requests. After a specified time or if you publish a new post, the cache will be cleared and generated once again. This method is the fastest available, but it will break some functionality like plugins which add dynamic content to your blog or count page impressions since they are executed only once. Note: If you want to use this plugin and the PHP Compiler Cache APC together, have a look at this posting from Mark Jaquith.

And of course…

Use the current WordPress version

Yes, update to the latest available WordPress version. Using always the most stable release gives you new newest features, security fixes and performance optimizations.

Disable unused plugins

Open your plugin management page and check if you really need all installed plugins. Did you in install some of them just for testing purposes or is their functionality already included in the latest WordPress version? Deactivate them to speed up PHP parsing and processing time.

Optimize your theme

Other hints like reducing HTTP requests, compression and so on can be found on the blog of Paul Stamatiou.

55 Comment(s) »

Comment by Ajay

Posted on February 16, 2007

I’ve had bad problems with the internal WordPress cache with high CPU usage. I now use wp-cache.

Comment by Lloyd Budd

Posted on February 16, 2007

Brilliantly concise! Gorgeous presentation.

(A problem that I would like to have, but likely never will)

Comment by Ant Eksiler

Posted on February 16, 2007

Will changing the MySQL cache to 1 effect any of the plugins like post ratings and wp-poll?

Comment by RAKESH

Posted on February 16, 2007

Y4+1 Ways To Speed Up WordPress With Caching

Comment by Rob Marsh

Posted on February 16, 2007

I’ve just written a small plugin (Plugin Output Cache) to help plugin writers cache the output of their plugins. I’ve found that caching my own plugins this way can cut a running time of the order of tenths of a second down to a few microseconds. It seems to play well with WP-Cache too.

Comment by Del Simmons

Posted on February 16, 2007

Thanks for this helpful post! I’m going to have to try a few of these out!

Comment by Thilak

Posted on February 16, 2007

Great write-up! The first two tips sounded a bit techy, but they really did wonders to me!

Pageload speed is everything!

Comment by GetronX

Posted on February 17, 2007

Nice tip dude… i’ll do it.

Comment by jesse

Posted on February 17, 2007

Please note:
query_cache_type must be query-cache-type (like in query-cache-size).

jesse (:

Comment by Pod

Posted on February 17, 2007

nice information!! I didn’t know the wordpress cache configuration!

Comment by RYK

Posted on February 17, 2007

Great post. These are not just great techniques for more efficient wordpress, but any PHP MySQL website. Is there an equivalent of the WP Cache plugin for normal PHP sites? or can that piece of code be modified for other sites?

Comment by RONI

Posted on February 17, 2007

nice collection of tips, defiantly worth trying out!

Comment by Marcus

Posted on February 18, 2007

The only thing for the most website-owners is the “WordPress Internal Caching”, which speedup webpage endering. And that should be always “on”.

Comment by Keith

Posted on February 18, 2007

That’s a good piece of post. I have some WordPress sites which are facing slow performance. I believe some of your tips might be useful.

Comment by Marios Alexandrou

Posted on February 19, 2007

Thanks for the tips. I’m giving the ENABLE_CACHE suggestion a shot. Why do you suppose this option isn’t set by default? Are there possible negative consequences to using it?

Comment by Navdeep

Posted on February 20, 2007

Ill sure follow this tips. Thanks

Comment by xcache

Posted on February 20, 2007

Use xcache instead of APC/eaccelerator, it’s much better than any other php opcode cacher.


Comment by Owen

Posted on February 23, 2007

Excellent post. Will have to go over my WP sites with a toothcomb and see how I can speed them up ..

Comment by mxay

Posted on February 24, 2007

good post.
thank you.

Comment by Kelson

Posted on February 25, 2007

Just a word of warning on ENABLE_CACHE. It seems that WordPress’ caching code doesn’t work properly with PHP 5.2.

Comment by Suhdesoppa

Posted on February 26, 2007

Thanks, definetely worth trying.

Comment by muztagh

Posted on March 2, 2007

Thanks, I have implemented some of these methods already, now I will give a try to others.

Comment by Will

Posted on March 11, 2007


I run a few hundred web sites for clients and a few of them get dugg and slash dotted at the same time.

Normally this takes care of it. :)

# 290 volunteer server distribution network – uncomment to use when being slash dotted!

# RewriteCond %{HTTP_USER_AGENT} !^CoralWebPrx
# RewriteCond %{QUERY_STRING} !(^|&)coral-no-serve$
# RewriteRule ^images/(.*)$$1 [R,L]

he-he Works great!

Take Care,


Comment by Alexander Orlov

Posted on March 16, 2007

WP-Cache 2.1 – the one an only! A really great performance boost plugin. The other tips did not improved the page download time I have measured.

Comment by Jeremy

Posted on March 24, 2007

This post is “most excellent”, to quote Bill and Ted. As my site gets more popular I am always looking for ways to optimize my bandwidth and provide a better experience for my readers.

Comment by forum

Posted on April 8, 2007

It’s really works for me.Thanks dude.

Comment by Apache Guru

Posted on May 29, 2007

You are missing 1 little piece though, you should encourage people to also implement a server-side caching scheme to send out the correct caching headers with static content such as images, javascript, css, pdfs, favicon.ico, etc..

Read about it: htaccess Caching

Great article! I subscribed to your feed

Comment by Matt Cutt

Posted on May 29, 2007

Awesome! I hope this post gets spread around the net, we would all benefit by implementing faster blogs and websites. Thanks!

You will also like reading about the 14 Top Methods for faster, speedier sites

Comment by nlonssocqe

Posted on June 18, 2007

Hello! Good Site! Thanks you! wetadzsyxenze

Comment by Harsha

Posted on July 10, 2007

A great Post with full of information. Thanks a lot And I am using WP-Cache right now. I have no idea about my server usage since my hosting is a shared one

Comment by hakim

Posted on July 21, 2007

nice thanks for this best help

Comment by forum

Posted on August 31, 2007

nice thanks

Comment by Soverato News

Posted on September 4, 2007

Sometimes i try to use cache plugin, but always have problem with them, then i switch to a wordpress with no cache. What more that one time slow wordpress are plugin not regulary builted.


Comment by Tom

Posted on September 18, 2007

many thanks for your information..

Comment by forum

Posted on September 19, 2007

thanks you …

Comment by youtube

Posted on September 19, 2007

yaşasın forumlar :D

Comment by forum siteleri

Posted on September 19, 2007

thank you forum siteleri

Comment by ZORGECE.COM

Posted on September 20, 2007


Comment by cep download

Posted on September 22, 2007

thank you.

Comment by fikra

Posted on September 22, 2007

good site. very thanks.

Comment by xxxteenwebcam

Posted on September 28, 2007

Thanks for tips.

Comment by norman

Posted on October 2, 2007

nice tips, i have been thinking a lot on how to optimize my site and finally i found a guide like your post. thanks a lot

Comment by Giel

Posted on December 5, 2007

Thanks, My site is very slow and i will try to do some experiments with your information. I am just a beginner … But your tips seems to be concreet.

Comment by guru

Posted on December 10, 2007

Cool tips.Kudos to you! :)

Comment by Linux

Posted on December 30, 2007

Custom memcached blog software rewriting does help a lot. Nice tips you have in your post, thanks!

Comment by doktor

Posted on January 27, 2008

thax for this articles.forever wordpres

Comment by Performance

Posted on January 28, 2008

Nice tips. From the very beginning you should run your blog with performance in mind…

Comment by Steven

Posted on February 8, 2008

In addition to page caching with WP-Cache, one can easily offload images with a service like

This significantly minimizes the number of HTTP requests that the server has to handle while delivering images from an external cache server.

Comment by seven rays

Posted on February 21, 2008

I recently installed the wp-cache plugin, following your recommendation. So far, it has proven very useful. Thanks.

Comment by lutfi rifai

Posted on February 22, 2008

very helpfull tutorial arne…. time to optimize my wordpress blog

Comment by zack

Posted on February 22, 2008

i’m using wp-cache or wp-super-cache. very helpful plugins

Comment by t-shirts

Posted on March 15, 2008

The “Digg Effect? can be detrimental to your site in horrible ways that make the hits to your site not worth it. I mean, what use is it getting 50000 hits at once when it just shuts your site down and everyone thinks that you must be ‘unprofessional’ because you don’t have a site that can manage the load. These tips are great – and help us all to get prepared for that proverbial day when we will experience the Digg Effect for ourselves. I mean, in a site’s career, it has to happen at least once!

Comment by VIKTOR

Posted on April 18, 2008

Good job! Thanks for this post! Pageload speed is good! Thank You.

Comment by oil paintings from photos

Posted on May 2, 2008

Thank you for this information. I have no idea about reducing http requests and so the link to Paul’s work is super helpful.

Comment by Tim

Posted on May 4, 2008

The WP-Offload plugin can help you mitigate the Digg effect since it will redirect HTTP requests for images to external cache servers at a very low bandwidth cost. That will result in much less load on your server. Combined with WP-Cache, you can really ensure you’re getting out the maximum performance out of your server.

61 Trackbacks (30 random links are shown)

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Comment moderation is in use! It may need up to a day until your comment appears.
Please don't submit it twice.