How to speed up WordPress with Redis cache

Speeding up WordPress with Redis cache is a few simple steps. Redis is an in-memory database that can be used as a data store or cache. Redis is the perfect solution for speeding up WordPress and any other software that supports Redis caching. In this article, we are going to show you how to set up WordPress caching with Redis on a Linux based VPS.

1. Installing Redis on VPS Linux

We will assume that WordPress is already installed on your system, so we will skip this WordPress installation step. If you don’t have WordPress installed, you can skip to the article on how to install WordPress on a Linux VPS.

Installing Redis is straightforward. If you are using an Ubuntu VPS run the following command to install Redis:

apt-get install redis-server

For more detailed instructions, you can read the article on How to Install Redis on an Ubuntu VPS.

If you are using CentOS VPS, you can use the following command to install Redis:

yum install redis

Make sure you have EPEL (Additional Packages for Enterprise Linux) and the repo enabled on the server.

Start and enable Redis at system boot:

systemctl start redis.service
systemctl enable redis.service

2. Installing Redis PHP Extension on VPS Linux

In order to be able to use Redis as an object cache for your WordPress site, you need to install the PHP Redis extension. This will allow WordPress to communicate with the key-value of the Redis store.

On Ubuntu, run the following command:

apt-get install php-redis

On CentOS, run the following command:

yum install php-pecl-redis

3. Installing the Redis Caching plugin in WordPress

Log into your WordPress dashboard and navigate to Plugins> Add New. Enter in search Redis and install the plugin Redis Cache Object from the list. After the installation is complete, go back to plugins and enable the plugin Redis Cache Object

Then go to Settins> Redis and click on Enable Cache Objectto enable object caching in WordPress. The default config should work out of the box, Redis listens on default addresses by default will listen on the port 6379

4. Make sure WordPress caching is working

To check if caching works in WordPress with Redis, you can connect to the server via SSH and run the following command:

redis-cli monitor

Using the Redis monitor, you will be able to see all requests being processed by the Redis server, and this will help you understand what is happening with the database. The output should be similar to the one below:

# redis-cli monitor
1510415208.863435 [0] "PING"
1510415208.865491 [0] "GET" "wp_:default:is_blog_installed"
1510415208.870259 [0] "GET" "wp_:options:notoptions"
1510415208.870433 [0] "GET" "wp_:options:alloptions"
1510415208.871197 [0] "GET" "wp_:site-options:1:notoptions"
1510415208.875126 [0] "GET" "wp_:options:uninstall_plugins"
1510415208.882241 [0] "GET" "wp_:wordfence:alloptions"
1510415208.913368 [0] "GET" "wp_:site-options:1:notoptions"
1510415208.913547 [0] "GET" "wp_:site-options:1:notoptions"
1510415208.916283 [0] "GET" "wp_:site-options:1:notoptions"
1510415208.916434 [0] "GET" "wp_:site-options:1:notoptions"
1510415208.947299 [0] "GET" "wp_:site-options:1:notoptions"
1510415208.947480 [0] "GET" "wp_:options:can_compress_scripts"
1510415208.947637 [0] "GET" "wp_:site-options:1:notoptions"
1510415208.954565 [0] "GET" "wp_:posts:last_changed"