Cache WordPress Using Redis

My original interest in this methodology came when I stumbled across Eric Mann’s article, Ludicrous Speed: WordPress Caching with Redis. Of course this led to more in-depth research which produced the solution I eventually settled on which is our modified version of Wp Redis Cache by Benjamin Adams. So, in this tutorial I will walk you through using Redis as a WordPress cache on either Debian or Ubuntu.

Warning: This setup has only been tested on this site. I make no guarantees that this tutorial will work with your WordPress installation. This article should be considered a primer on caching WordPress with Redis only!
Without further ado, first we need to install Redis and the PHP Extension for Redis. This can be accomplished by running the code below in terminal.

Next, move the folder wp-redis-cache to the plugin directory and activate the plugin. In the admin section you can set how long you will cache the post for. By default it will cache the post for 12 hours. Note: This plugin is optional and is used to refresh the cache after you update a post/page. Note I have modified the original version, as I mentioned above. to delete the entire site cache on add/update/delete of posts, pages and comments. Also, in the original version, we were required to modify the index.php of our WordPress installation, however that approach required re-editing the index.php file after every update. That was not going to work for us, so we decided to use a location alias in our Nginx config as an alternative. The benefit of this route is that updates no longer affect our Redis Cache plugin. Below you will see the snippet that we added to our config as well as the Apache version.

So to recap the steps to implement the attached Redis Cache plugin we will need to:

  • Copy wp-redis-cache from the download below to your WordPress plugin directory.
  • Copy wp-redis.php to the root directory of your WordPress installation.
  • Modify either your Nginx or Apache configuration to alias index.php to wp-redis.php
  • Restart your web server.

After following the steps above you will be Caching your WordPress install using Redis.

download-icon Redis Cache Plugin Download

Did you find this article useful? Why not share it with your friends?

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.