How to speed up WordPress using Redis cache is such a simple thing. Redis is an in-memory database that can be used as a data store or cache. Redis presents itself as an ideal solution to speeding up WordPress and any other software which supports Redis cache. In this article, we’re going to show you how to set up WordPress caching with Redis on a Linux VPS.

How to Speed up WordPress with Redis Caching

Installing Redis on Linux VPS

We suppose that WordPress has been installed already on your system, so this step will be skipped.

It’s simple to install Redis. If you’re using a Ubuntu VPS, run this command to install Redis:

apt-get install redis-server

If you’re using a CentOS VPS, you can use the following command to install Redis:

yum install redis

Make sure you activated repo EPEL (Extra Packages for Enterprise Linux) on your server.

Start and activate Redis on system boot.

systemctl start redis.service
systemctl enable redis.service

Installing Redis PHP Extension on Linux VPS

In order to use Redis as an object cache for your WordPress site, you need to install Redis PHP extension. It will allow WordPress to contact the Redis key-value store.

Run this command on Ubuntu:

apt-get install php-redis

On CentOS, run the following command:

yum install php-pecl-redis

Installing Redis Caching Plugin in WordPress

Log in to your WordPress dashboard and navigate to Plugins → Add new. Search for Redis and install Redis Object Cache plugin from the list. When the installation finishes, navigate to Plugins and activate the Redis Object Cache.

Then navigate to Settings → Redis and click on Enable Object Cache to enable the object caching in WordPress. The default configurations should work out of the box with the default Redis listening address being and the default listening port being 6379.

Verify Redis Caching on WordPress

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

redis-cli monitor

By using the Redis monitor, you will be likely to see all the requests processed by the Redis server which will enable you to understand what is happening to the database. The output should be similar to the following:

# 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"

That means Redis is working for your WordPress website. From now on, whenever you get an option or post meta, WordPress will check from the Redis cache first. If it doesn't find what it needs, then it will make a database call. So it reduces the load on your database quite a lot.

What do you use Redis for? Let us know in the comments.

Leave a Reply

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