I like the web pages to be snappy, including my blog. I found my blog to be bit slow after I moved to WordPress even after performance tuning. After looking around for a solution I came across memcache back-end for WordPress object cache which can be downloaded from here. You have to drop the file object-cache.php into wp-content/. You will have to specify the memcached servers by adding the following lines to wp-config.php.

global $memcached_servers;
$memcached_servers = array('default' => array('127.0.0.1:11211'));

My blog loaded faster than before, it was all good. Afterwards I wanted to install the memcache back-end for WP object cache on my mother’s blog using the same memcached server. I just dropped the wp-config.php file into my mother’s installation of WordPress. That’s when things became awry. My mother’s blog started to redirect to my blog :( . After looking at wp-config.php closely it was clear to me it was designed for WordPress MU. However I didn’t want to give up on using memcache with WordPress. Looking even closer I noticed that I can specify the global variable $blog_id and it would be perpended to the memcache object key. I added the following line to wp-config.php in my mother’s WordPress installation in addition to the two lines above and applied this patch (patched object-cache.php).

global $blog_id;
$blog_id = 'priyani_mohanjith_net';

That’s it, both my blog and my mother’s blog became fast and it was working without any issues. Hope this helps someone who wants to use the same memcached server with multiple installtions of vanilla WordPress. You cannot use this technique or memcache unless your blog is self hosted on a server where you have full control.

If you enjoyed this post, make sure you subscribe to my RSS feed!