This website uses cookies

Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.

CloudwaysCDN — a powerful solution that offers superior performance and satisfied global audience for your business. Read More

How to Configure Redis Cache on WordPress

Updated on  23rd August

6 Min Read
wordpress redis cache
Reading Time: 6 minutes

Speed, performance, stability, and superior support; these are the four ingredients of best WordPress cloud hosting that are crucial in providing high-performing server setups to our satisfied customers. We are always on the lookout for next-gen technologies that enhance the performance of our managed cloud servers.

Get to know about WordPress speed up tips that are relatively simple to implement and help you save a lot of time on website optimization.

This tutorial is about WordPress Redis cache that is now universally available on Cloudways servers. Redis is a data structure server that can be used as a distinct web server. In other implementation scenarios, its caching mechanism can be combined with MySQL or MariaDB to speed up WordPress database queries. However, enabling Redis on Cloudways servers requires a bit of work and in this tutorial, I am going to show you the correct procedure for adding the Redis cache support for WordPress.

Table of Contents

Adding WordPress Redis Cache Support

Like every other procedure that directly affect the live WordPress website and underlying servers, you need to take several precautions when adding Redis cache support:

  1. Either backup your WordPress app or clone it to a new server.
  2. To avoid conflict between application data of multiple websites on a single server, you need to be extra careful when adding Redis on all of them. Make sure that you are working on the correct website when adding Redis.
  3. It is better to first test this method on a test website. Once you are confident that everything configured correctly, proceed to the live website.

Install Redis Cache

The first step is the activation of WordPress Redis on Cloudways server.

To do this, first, you need to log in to your Cloudways account and navigate to Servers → Settings & Packages → Packages and then click on install Redis.

This will take some time to install WordPress Redis cache on your server.

WordPress Redis cache

On the Cloudways server, I will use the Redis caching feature to further optimize the WordPress object cache. By default, WordPress has a built-in caching rule that caches database queries on single page loads [read more]. To use this caching persistently across other page loads, I need to use a “drop-in” object-cache.php generated by Redis Object Cache plugin.

W3TC also added support for Redis in their 0.9.5 update and the method of adding Redis is very straightforward. On Cloudways, you can configure Redis cache using any third party Redis supported plugin.

Although, there are many free cache plugins available on the WordPress plugin repository that helps to make WordPress website load faster by adding different caching rules. On Cloudways, after Breeze caching plugin we recommend using W3 Total Cache (W3TC) as it is compatible with our hosting stack. In our guide, I will be using W3TC. However, if you are not using W3TC, I recommend using the Redis Object Cache Plugin.

Configure Redis Cache on WordPress

In this tutorial, I will cover two different methods of configuring the Redis cache on WordPress.

Method 1: Use W3TC to Configure Redis Cache

As stated earlier, configuring Redis via W3TC is very easy. Just log in to your WordPress Admin and navigate to Performance → General Settings → Object Cache. From the drop-down menu, select Redis and make sure that the option is enabled.

Use W3TC to Configure Redis Cache

Test Whether Redis Is Working on the WordPress Website

You can easily test whether Redis is working either through W3TC or the SSH terminal.

To test via W3TC, navigate to Performance → Object Cache. Click the Test button. If you see a Test passed the message, the Redis cache is working fine. If you are not sure about how Redis works, we suggest keeping the settings on default.

You can also test Redis via the SSH terminal. To access SSH terminal on Cloudways, navigate to Servers → Select Server → Master Credentials and click the Launch SSH Terminal button. Login to the SSH with the Master Credentials. Run the command below.

If everything is properly configured, you should get the message OK. Next, visit your website or navigate through pages of the website and you should receive output similar to the following:

Redis Is Working

To stop the monitoring, hit Ctrl+C on your keyboard.

Method 2: Use the Redis Object Cache Plugin

If you are not using W3TC plugin or Object Cache in W3TC, then I recommend the Redis Object Cache plugin. The process of setting up this plugin is slightly more complicated. It is also recommended to keep the Object Cache option in W3TC disabled.

Step 1: Turn off Object Cache in W3TC

In the first step, turn off the object cache rule in W3TC. For this, navigate to Admin → Performance → General Settings. Then, scroll to the Object Cache option, uncheck it, and empty the cache.

Step 2: Install Redis Object Cache plugin

Next, we need to install the Redis Object Cache plugin. It installs a PHP script that helps WordPress communicate with Redis. After installing the plugin you need to activate it. Navigate to Settings → Redis and click on “Enable Object Cache” and make sure status shows “Connected”. If not, then make sure you have enabled Redis in the Cloudways platform as discussed above.

Enable Object Cache

Step 3: Edit the wp-config.php file

At this point, you must take a backup of the wp-config.php before proceeding.

In the wp-config.php, I will add a cache key salt using the define (‘WP_CACHE_KEY_SALT’, ‘yourURL.com’); under * Authentication Unique Keys and Salts.

You can use any unique string in your URL, but for Cloudways, I recommend that you use the URL of your website. It is especially helpful if you are hosting multiple websites on a single Cloudways server. You can read more about it here.

To make the cache persistent across all page loads, we need to add define (‘WP_CACHE’, true);

The final wp-config.php file will resemble something like this:

Step 4: Monitoring and Verifying Redis Cache Working

You can check via the command redis-cli monitor in the SSH terminal or you can check via the Redis Object Cache plugin settings. To check if Redis is connected you can navigate to Admin → Settings → Redis. You will see something like this:

Enable Object Cache

Conclusion

Cloudways has come a long way. Our commitment to quality, speed, performance, and customer support has made us gather a loyal community of followers. And, like any other customer-focused company, we value the feedback of our customers. Redis Cache is an outcome of the feedback we received from some of our customers. We already had Varnish and Memcache in our arsenal, a basic WordPress site hosted on Cloudways with Breeze can be loaded in just 37ms. Its performance is at par with any other cache plugin out there and it is completely plug-and-play; all this at zero expense.

This tutorial details the process of adding Redis cache to WordPress websites hosted on Cloudways managed cloud servers. If you wish to clarify a specific point or would like to contribute to the discussion, please leave a comment below.

Share your opinion in the comment section. COMMENT NOW

Saud Razzak

Saud is the WordPress Community Manager at Cloudways - A Managed WooCommerce Hosting Platform. Saud is responsible for creating buzz, spread knowledge, and educate the people about WordPress in the Community around the globe. In his free time, he likes to play cricket and learn new things on the Internet. You can email him at m.saud@cloudways.com

Make Your WordPress Website 100% Faster.

Host it now on Cloudways WordPress Hosting Platform.

Get Our Newsletter
Be the first to get the latest updates and tutorials.

THERE’S MORE TO READ.