Finished some preliminary work on WordPress Caching

February 15th, 2004
WordPress Hack

Here are some examples:
Here is a WordPress 1.1 beta blog showing 300 posts.
Here is the same blog, cached with my method

Take a quick look at the bottom of the page for the generation times. The number in small letters in the center is for the main entries to be generated and displayed and the larger number to the left is the time for the whole blog to be generated.

A little more work is required to make this a functional hack. The categories and comments sections (along with archives and others) do not use the cache at this point to display the pages. Only the index page uses the cached entries and produces all the right links. Consequently, some more work is required to update the cache when some information is edited or added. This could include adding or editing a post or addition of comments and/or trackbacks. However, with a larger numbers of posts and links, this cache speeds things up quite a bit from what I can tell. I had to mess around with quite a few of the functions to get them to work correctly with storing a variable instead of echoing them. If someone is interested in the code, leave a comment or email me.

What do you think? Is this something worth investigating further?




  1. Lennart says:

    Hi, I was thinking the same thing a couple of times already. For my webpages I use PEARs CacheLite. But you don’t need to change wordpress to dump its output into variables, use phps’ caching functions. Here is an example of how I do it. This is the the top and the bottom of a webpage:

    $cache = new Cache_Lite($cacheOptions);
    if ($data = $cache->get($cacheId)) {

    // put whatever php/html here


    Hope this helps…

  2. Lennart says:

    Oh, a wordpress bug striked in my post above. WordPress always removes “id equals to” code from comments. The first line should read

    $ c o d e I d = ' b a n d s ';

  3. Mark says:

    Interesting. I should look into their version. However, your hack would require a new application to be installed. I guess I am trying to do this inside wordpress. Though I am sure there are lots of lessons to be learnt from cache_Lite!
    Thanks for the suggestion!

  4. till (1 comments.) says:

    hey, is your cache plugin available?

Obviously Powered by WordPress. © 2003-2013

page counter