Skip to content
WordPress + Memcached

I use the Memcached Redux plugin on all of the servers and WordPress installs that I manage. I want to share the proper way to get your WordPress and Debian server setup to utilize Memcached. This guide will also set your server up correct for a server with multiple WordPress instances.

What You’ll Need


  • WordPress Self-Hosted
  • Debian Server OS (Example: Ubuntu)


  1. Download the Memcached Redux plugin and put it in your /wp-content/plugins/ directory

  2. Don’t Activate the plugin (never activate the plugin)

  3. copy the object-cache.php file from /wp-content/plugins/memcached-redux/ directory to the wp-content directory.
  4. Open your wp-config.php file for editing
  5. In the “Authentication Unique Keys and Salts” section place the following line below the $table_prefix definition (required for multi-install servers):
define('WP_CACHE_KEY_SALT', md5( DB_NAME . $table_prefix . __FILE__ ) );
  1. Save the file
  2. From your server’s command line install memcached
sudo apt-get install memcached
  1. From your server’s command line install php5-memcached

If you have php5:

sudo apt-get install php5-memcached

If you have php7:

sudo apt-get install php-memcached
  1. Restart apache
sudo service apache2 restart


Why shouldn’t I activate the Memcached Redux plugin?

The plugin serves as a placeholder for the object-cache.php file. It can also serve as a way for you to know if there are updates in the future. If you do activate it you’ll receive the following PHP Fatal error and your site and/or admin will display a White Screen of Death (WSOD).

PHP Fatal error:  Cannot redeclare wp_cache_add()

This is because when a plugin is activated WordPress will execute the code contained in it’s main php file. Copying the object-cache.php to the wp-content/ directory is all that’s needed to make the plugin work.

Why do I need to add the WP_CACHE_KEY_SALT definition in wp-config.php?

This step is good for anyone to do, but is highly recommended for servers that host multiple WordPress installations that are using memcached.

An example of what could happen if you don’t take the step on a multi-install server is any blog using a common database prefix (default is wp_) could take on portions of other sites using the same prefix.

I haven’t done extensive testing, but it appears that sites that use different database prefixes are likely ok to exclude this extra definition, but better to be safe than sorry.

Why did you write this guide?

I’m neither the plugin author or a contributing developer on the memcached project, but I am an enthusiastic user. That said, the information above was gleaned from multiple sources and I couldn’t find a comprehensive guide on how to fully install and use the Memcached Redux plugin.


Purrly Digital LLC cannot be held responsible for the functionality of this code. Please make sure you test it on a development site before adding the code to your production website. There is no support available for this (and other) code snippet(s) posted on this website. If you’d like Purrly Digital to do custom development to help with your custom implementation please send a contact request.

This Post Has 5 Comments

  1. I’m keen to speed up wordpress for logged in users. (Page caching is all very nice but only when it’s turned on which is not the case for logged in users so it’s useless).

    But here’s the question. Supposing a DB query (select x, y, z, from xxxx) goes into the object cache. Then some other user (perhaps an admin) causes an update to that table. Now a third user comes along and needs the same info. If that info comes from the object cache it’s going to be old data right? If I am wrong let me know. (I just want to save my self some time since I don’t want to have that “old data” problem on my site).

  2. Thank you for the great post. Please tell me, can I delete the plugin after copying the object cache php file to wp content. Also, how can I test to make sure that memcached is actually working ?

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back To Top