Chat with us, powered by LiveChat

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.

How to Improve WP Admin Performance Using Redis Object Cache

October 7, 2019

7 Min Read
redis wordpress
Reading Time: 7 minutes

Fast speed, high performance, stability, and great support have always been the main ingredients of Cloudways managed WordPress hosting. Our platform offers a PHP-powered stack with multiple cache layers that serve websites at an amazing speed.

Redis Object Cache (globally available on every Cloudways server as an optional install) is an important part of this cache layers.

In this article, you will learn to use it for your WordPress site and see the backend perform as fast as the frontend by using cache plugins like Breeze. For more advanced users, this article also covers how to use the Redis Object Cache with W3TC.

What Is Redis and How It Works?

By default, Cloudways servers use Memcached as an object cache, and it works just fine. Redis is a more advanced and rich implementation that can do all that Memcached does and then more.

REmote DIctionary Server (Redis) is an in-memory, persistent, key-value database, also known as a data structure server. One important factor that differentiates Redis from similar servers is its ability to store and manipulate high-level data types (common examples include lists, maps, sets, and sorted sets).

Redis’s caching mechanism, when combined with MySQL or MariaDB, speeds up WordPress database queries. Learn more about Redis on this article, or to dig a bit deeper into the rabbit hole, this one.

Redis’ performance, simplicity, and micro-data structures manipulation allow it to perform significantly better than traditional relational databases. Enabling Redis on Cloudways servers requires a few steps, and this article will guide you in integrating Redis Object Cache support on your WordPress sites hosted at Cloudways.

How Does Redis Interact with WordPress Cache Plugins?

Unlike cache plugins, that run from inside the WordPress site, Redis is a server-side cache. WordPress cache plugins are made to accelerate the rendering of the website frontend by caching static versions of the pages that don’t run any code (for instance, the regular pages and posts that are served as static cached content).

Let’s say your WordPress site offers memberships, has protected content and discounts for members on the connected WooCommerce store (which also sells courses that are made with your preferred LSM System for WordPress). All these plugins, plus their add-ons (that extend the plugins) may mean that there are as many as 20 active plugins on the WordPress site.

We assume that you already have a properly configured WordPress cache plugin serving your pages. But at the backend, on your WordPress Admin area, things aren’t that fast because the dynamic content couldn’t be cached.

Integrating Redis will result in a noticeable improvement in the backend operations, drastically reducing the waiting time. Redis will cache and handle database queries and data structures in order to make your backend experience as fast as the frontend.

Before You Enable Redis Cache Support

Like every procedure that directly affects your server and your WordPress site, you should take precautions before enabling Redis cache support.

Back up Your Server

The first thing is to back up your server so that you have a safe restore point to revert to in case things go wrong.

Use a Clone/Staging Site to Test

You should test all site changes on a clone or staging environment. Once you are satisfied that everything is working as intended, you can simply “Push” the changes to the live site.

Prepare Each WordPress Install wp-config.php

To avoid conflicts when hosting multiple websites on a single server, add the following lines to the wp-config.php file:

At the very top, just below the <?php tag on the top of the file, add this:

<code>define('WP_CACHE', true);</code>

wp-config-01

And, at the first line on the Salt Keys Section of the file, add this:

<code>define('WP_CACHE_KEY_SALT', ‘yoursite.com');</code>

wp-config-02

The WordPress Cache Salt Key (yoursite.com in the example above) could be anything you like. It must be a unique key for every WordPress install on that server. This way we are sure Redis properly handles it. Using each install domain is the recommended option in this process.

Activating Redis on the Cloudways Platform

First, log in to the Cloudways Platform. Once in, navigate to Servers → Settings & Packages → Packages → Redis, and click Install.

redis-server-01

The install process will take some time. Once it finishes, you will see Redis has been installed on your server.

redis-server-02

Method 1: Using Redis Object Cache Plugin

Now that the Redis is properly installed, the next step is to install and set up the integration plugin on your WordPress site. This is a simple and easy process with three steps: Install, Activate & Test.

Using Breeze Cache Plugin

Cloudways has developed a simple and powerful WordPress Cache plugin, Breeze that works seamlessly with Redis.

Install and Set up Breeze

Breeze and Redis are two separate caching systems. As Breeze caches WordPress site contents to speed up the page speed to your visitors, Redis caches the queries, transients, and other data structures for the WordPress Admin.

Install Redis Object Cache Plugin

Log in to your WordPress site, go to WordPress Admin → Plugins → Add New. Search for “Redis Object Cache” and install the plugin.

redis-wp-01

Click Activate and you will be redirected to the main Plugins page. Verify that the Redis Object Cache plugin is active. Before Redis starts caching your site you have to connect the plugin to the server.

redis-wp-02

Now just go to WordPress Admin → Settings → Redis and click the Enable Object Cache button.

redis-settings-01

Activate and Verify That Redis Object Cache Is Working

This sometimes (but not always) will log you out. Just log back in, go back to the page and you will see that Redis is now connected.

redis-settings-02

You can also check at the WordPress Admin → Settings → Breeze → Database if Redis is caching your backend operations. When you have Redis Object Cache disabled, you will always have a few transient options to optimize:

breeze-db-clean-01

After you have Redis Object Cache enabled, you will see those transient options are now 0 (zero), which means they’re being cached by Redis instead of being stored by WordPress.

Redis is working as you can see below:

breeze-db-clean-02

When and Why You Should Flush Object Cache?

Normally we don’t need to flush the object cache, but sometimes it is the only option in cases where backend operations aren’t being registered such as a plugin activation/deactivation.

All you have to do is to go to WordPress Admin → Settings → Redis and then click the Flush Cache button. It’s also a good idea to flush/purge all other caches – WP, Varnish. Breeze has a dedicated option for purging Varnish that cleans out everything and recreates the cache from scratch.

If your plugin doesn’t have a dedicated purge option, go to the Cloudways Platform, navigate to Servers → Manage Services and click Purge for the Varnish to clean the Varnish cache at the server level.

Method 2: Using the W3TC Plugin

W3TC s a popular plugin that allows total control over every single aspect of system-wide caching. For most users, there are simply too many settings, each with many options and sub-options. When properly configured, it’s powerful and fast, however, many users now opt for easier solutions such as Breeze.

To set up Redis Object Cache to be managed by W3TC, you don’t have to install any additional plugin. When using W3TC, just go to the WordPress Admin → Performance → General Settings → Object Cache. First, select the checkbox Object Cache: Enable to activate the option, select Redis from the drop-down menu below it, and hit Save Settings & Purge Caches:

w3tc-redis-setup

Test Redis Object Cache Response via Terminal

Next, you should test if everything is working fine. This is done by a simple command. For this launch the terminal. Note that for this to work properly, you need to enable SSH access to the application.

ssh-access

In the Terminal, access the server, type the line below and hit Enter.

<code>redis-cli monitor</code>

If everything is properly configured you should get the message OK, followed by the pages that are being cached by Redis:

Conclusion

Like all customer-focused organizations, we value the feedback of our customers. Redis Object Cache is an outcome of the feedback we received from our customers. We already had Varnish and Memcached available at our arsenal, and a basic WordPress site hosted on Cloudways with Breeze can load in just 79ms.

This tutorial guides you on configuring Redis Object Cache support to your WordPress sites hosted at Cloudways. The goal of this implementation is to speed-up your backend operations by persistent caching queries, transients and fundamental data structures that otherwise would use your WP and DB, and thus slowing down the websites. 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

Share This Article

Start Growing with Cloudways Today!

We never compromise on performance, security, and support.

Fabio Fava

Fabio is a brazilian extreme air sports pioneer, flying paragliders since 1996 and aerobatics paragliders since 2000. He's producing websites and web content since 2005, using WordPress since 2010 and professionally since 2015.

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

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!