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.
# Install Redis Server and PHP Dependency sudo apt-get install redis-server php5-redis
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.
# Nginx Config location /index.php { alias /var/www/oitibs/wp-redis.php; } # Apache Config Alias /index.php /var/www/oitibs/wp-redis.php
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
towp-redis.php
- Restart your web server.
After following the steps above you will be Caching your WordPress install using Redis.