WordPress Database Cache

After spending a while looking into caching methods on WordPress, I have started work on a way to reduce database server load.

Most caching methods for WordPress involve creating static (Wp-Cache) or semi-static (Staticize Reloaded) pages and these are very good at reducing web and database load but are very quirky on sites with a lot of dynamic content.

Although the database cache does not reduce web server load, it does reduce the amount of queries sent to the database server.

At the time of this posting, my home page performs 79 queries to the database server.

With database caching enabled, 67 queries were retrieved from the cache and only 12 queries were made to the database server.

Even with the cache timeout set to the minimum of 1 hour, the load on a database server can be dramatically reduced on busy sites.

The WordPress database class (WPDB) is a modified version of an earlier release of ezSQL and can be easily replaced by creating your own database class in ./wp-content/db.php which is the same method the WordPress site uses for its HyperDB.

HyperDB is a replacement for the standard WPDB class which adds the ability to use multiple databases.

The cache I have created just drops into the wp-content directory and extends the current version of ezSQL for use with WordPress.

Features

  • Uses the cache feature within ezSQL
  • No caching of WordPress options, admin pages or previews
  • No caching of any SQL that makes use of RAND
  • Cache timeout can be set to a minimum of 1 hour (default)
  • In case of emergency, the cache can be switched off or even made to revert back to the WordPress default wpdb class from within wp-config.php

The script and documentation will be available soon – watch this space…

In the mean time, you can see the cache statistics at the bottom of these pages.

Update

Sunday, February 3rd, 2008 – The project pages for this post are available in the ezCache section.

About Martin Guppy

It was in my younger years, living in Kidderminster, England, UK, I picked up my first home computer - a Sinclair ZX Spectrum+ (1984). From that point on, I haven't been able to shake what seems to be my new found purpose. My 'hobby' has had me spend much of my life being surrounded by computers and gaining valuable knowledge through the art of trial and error. Thus leading me to developing Open Source Projects, such as CRIMP, Whap, Genwulf and maintaining a small cluster of my very own. I know I'm good at what I do. I also know I'm a keen and rapid learner. Should there be prospective information floating out there... I will consume it.
This entry was posted in Projects and tagged , , , , . Bookmark the permalink.

One Response to WordPress Database Cache

  1. Darren says:

    I’m desperate for this script!!! My server is going haywire! Please email me when you release it!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

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