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 Install and Configure Redis on WordPress (Boost Your Site’s Performance)

Updated on September 2, 2022

9 Min Read
WordPress Redis Cache

Redis is among the top WordPress caching tools to speed up your website. And that’s why it is globally available on every Cloudways server as an optional installation.

Cloudways believes in combining fast speeds, high performance, stability, and great support on its WordPress servers. Thus, it offers a PHP-powered stack with multiple cache layers, and the Redis Object Cache is a part of that layer.

This blog focuses on how to use Redis cache on your WordPress site and improve the site’s performance via cache plugins like Breeze. For more technically-sound users, this article also covers how to use the Redis Object Cache with W3TC.

What Is Redis and How Does It Work?

All Cloudways servers use Memcached as an object cache by default. However, WordPress Redis is a more advanced and rich implementation that does everything Memcached offers and provides additional features.

Remote Dictionary Server (Redis) is an in-memory, persistent, key-value database 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).

When combined with MySQL or MariaDB, Redis’s caching mechanism speeds up WordPress database queries.

Redis’ performance, simplicity, and micro-data structure manipulation allows it to perform significantly better than traditional relational databases. Enabling Redis on Cloudways servers is easy; keep reading to learn the steps to integrate Redis Object Cache on your WordPress sites hosted on Cloudways.

How Does Redis Interact with WordPress Cache Plugins?

Unlike traditional WordPress cache plugins, Redis is a server-side cache. WordPress cache plugins are built to accelerate a website’s frontend rendering 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 and protects content and discounts for members on the connected WooCommerce store (which also sells courses that are made with your preferred LMS for WordPress).

All these plugins, plus their add-ons, mean that there could be 50 (or more) active plugins on your WordPress site.

We assume that you already have a properly configured WordPress cache plugin serving your pages. But things aren’t that fast in your WordPress Admin area because the dynamic content is not being cached.

Managed WordPress Hosting Starting From $10/Month

Cut down server loads with Object Cache Pro, now offered for FREE on Cloudways, and enjoy speed boosts.

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

Why Does WordPress Need Redis?

A WordPress website with a laggy front and back end is disappointing. You can avoid poor user experiences and speed up your WordPress sites by integrating a caching mechanism like Redis cache.

With Redis enabled on a WordPress site, your visitors will get the content faster on your site. Usually, when a visitor requests data on a WordPress site, the backend starts doing MySQL query looks, which is time-consuming.

Redis stores important data in its memory that is readily delivered when requested to make things faster. So, Redis makes data retrieval faster, boosting performance and dramatically reducing response times.

Precautions Before Enabling Redis Cache on WordPress

Before enabling WordPress Redis cache on your WordPress site, you must take a few precautions. Ignoring these may directly affect your server and even result in bigger losses.

Create a Backup of Your Server

The first prerequisite is backing up your server, so you have a safe restore point to revert to in case things go awry.

And it’s super easy with Cloudways as it offers two backup options: on-demand and schedulable. The latter allows you to schedule the backup hourly, daily, and weekly.

The easy process is demonstrated in the image below, where you just have to make a few selections to manage backups securely.

Cloudways Backups

Use Staging Environment

Developers advise testing all site changes in a staging environment. Even if things go back, your actual site remains unchanged and unharmed. And you learn about the consequences as well.

Once you are sure that everything is working as intended, you can “Push” the changes to the live site. No changes are implemented to the live site until you “Push” them.

The staging environment is a replica of your existing website. It is not publicly available, and search engines can’t index a password-protected staging site.

Staging Environment

Add Code in the WP Config File to Avoid Conflict

If your site is hosted on Cloudways, you must make some changes in the wpconfig.php file to avoid any conflicts and run Redis smoothly.

Use an FTP software like FileZilla and PuTTy to access the wpconfig.php file. Follow the steps below:

  • Log in to your FTP client.
  • Connect to your host.
  • Locate the public_html file
  • Inside public_html, you’ll find the wp-config.php file.
  • Open the wpconfig.php file on any text editor
  • Add a line of code mentioned below just after the first line, PHP’s opening tag (<?php).
define('WP_CACHE', true);

wp-config-01
Scroll down on the same file and find the Authentication Unique Keys and Salts section. Add the below-mentioned line of code to the first line.

define('WP_CACHE_KEY_SALT', 'yoursite.com');

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 installation on that server. This way, we can be sure of Redis handling it properly.

How to Activate Redis on Cloudways Platform

Cloudways offers a quick one-click Redis installation. Follow the steps below:

  • Log in to the Cloudways platform.
  • Navigate to Servers.
  • Click Settings & Packages → Packages.
  • Locate Redis, and click on the “Install” button next to it.

Redis Installation in Cloudways platform

  • Wait till your server package updates.
    You’ll see a confirmation message at the top-right corner of the platform, notifying that the package has been updated.

Redis Package Updating

If you are using any other hosting provider that doesn’t provide the one-click Redis installation, you can still install Redis, but the process is: lengthy.

It contains the following steps, and each step takes its time.

  • Access your server backend via SSH terminal
  • Run multiple WP CLI commands to install Redis on your server.
  • Once Redis has been installed on your server, configure it from your WordPress website.

There are two methods to configure Redis on your site, and here they are:

Method #1: Using Redis Object Cache Plugin

Before the Redis Object Cache installation and configuration, we recommend installing a caching plugin like the Breeze cache plugin to optimize your site’s front end.

Breeze and Redis are two separate caching systems. Breeze caches your site’s content for improved speeds, and WordPress Redis caches the queries, transients, and other data structures for the WordPress Admin. So, with Breeze and Redis together, you get an optimized front end and back end.

Read our detailed guide to installing the Breeze cache plugin on your WordPress site.

Install Redis Object Cache Plugin

Follow the steps below to install the Redis Object Cache plugin to your WordPress site:

  • Log in to your WordPress site.
  • Go to your WordPress Admin dashboard.
  • Click Plugins → Add New.
  • Search for Redis Object Cache.
  • Click on the Install button.

Redis Object Cache

  • Activate the plugin by clicking on the Activate button.

Activate Redis Object Cache

  • After the activation, you’ll be redirected to Settings. Click Redis.
  • You will see the Drop-in is invalid status.
  • Click on the Enable Object Cache button to enable the status.

Redis Status Disable

  • Once the object cache is enabled, the status will change to Connected.
  • You will see a Flush Cache button on the bottom of the page. Let’s understand the use and need of this button.

Redis Cache enbale

We usually don’t need to flush the object cache. Still, it is sometimes the only saving grace when backend operations don’t work correctly, like the need for activating or deactivating a plugin activation.

The Flush Cache option is just for the object cache and is a good practice to Flush or Purge all the other caches.

Breeze, Varnish, and other cache plugins have dedicated Flush or Purge cache options that clean out unnecessary files from your site.

You can also purge the varnish cache from the Cloudways platform.

  • Navigate to Servers → Manage Services.
  • Click on the PURGE button.

Varnish Purge Cache

And to check if Redis is caching your backend operations, follow the steps below:

  • Go to your WordPress Admin dashboard.
  • Click Settings → Breeze.
  • Click Database Options.

If Redis Object Cache is disabled, you will see a few transient options to optimize:

Breeze when Redis disable

Once you have enabled Redis Object Cache, you will see the transient options as 0 (zero), meaning Redis is caching them instead of WordPress storing them.

Breeze when redis enable

Method #2: Using the W3TC Plugin

W3 Total Cache is a popular plugin that gives you full control over all aspects of system-wide caching. It provides many settings with several options and sub-options. When properly configured, it’s powerful and fast.

You don’t need any additional plugins to set up Redis Object Cache with W3 Total Cache. Follow the steps below:

  • Go to the WordPress Admin → Performance.
  • Click General Settings → Object Cache.
  • Mark the checkbox Enable to activate the option.
  • Select Redis from the drop-down menu.
  • Click Save Settings & Purge Caches.

W3 Total Cache Object Cache

Object Cache is now enabled on your site via W3 Total Cache Plugin.

Now it’s time to test the Redis Object Cache response via SSH terminal.

Testing Redis Object Cache Response via SSH Terminal

Running a simple WP CLI command helps you check if Redis Object Cache is working fine. Follow the steps below:

  • If you are a Cloudways user, log in to the Cloudways platform.
  • Click Servers and select your Server.
  • Click Master Credentials under Server Management.
  • Click on the Launch SSH Terminal button.
  • You’ll be redirected to a new tab.
  • Enter the server’s Master Credentials (username and password).
  • Run the below-mentioned WP CLI command.
redis-cli monitor
  • Hit the Enter button.

If everything is configured correctly, you will get the message OK, followed by the pages Redis is caching.

Redis-Cache-WP-CLI

Summary

This tutorial guides you on configuring Redis Object Cache support for your WordPress sites. This implementation aims to speed up your backend operations by persistent caching queries, transients, and fundamental data structures.

Cloudways collaboration with Redis Object Cache is an outcome of our customers’ feedback.

Even though we already had Varnish and Memcached available in our arsenal, we still went one step ahead for maximum speed boosts. A basic WordPress site hosted on Cloudways with Breeze can load in just 79ms.

If your site is not hosted on Cloudways, you’re missing on the speed boosts. Request a Cloudways product demo & learn about the product, its features, and how it works to help speedify your website.

Frequently Asked Questions

Q: Is Redis good for WordPress?

A: Redis Object cache speeds up your WordPress load time with each subsequent visit. The data serves faster next time the request generates, so the database doesn’t have to be queried again.

Q: How do I enable Redis cache in WordPress?

A: First, Install and Activate the Redis Cache Plugin on your WordPress website. Go to WordPress Settings > Redis, and click on the Enable Object Cache button.

Q: What is Redis in WordPress?

A: Redis is a fast caching solution for server-side applications such as WordPress. This open-source key-value store operates as an in-memory store and a cache.

Q: Is Redis cache free?

A: Redis Object Cache is a freemium plugin. You can use its limited features for free, but if you want to use the advanced features, you’ll have to get Object Cache Pro for $95/month. However, with Cloudways, you can save this amount and get Object Cache Pro for FREE on all its plans above 2GB.

Q: How do I turn off the Redis cache in WordPress?

A: You can disable the Redis Object Cache from the WordPress Settings. Go to Settings > Redis, and click on the Disable Object Cache.

Q: What is the difference between memcached vs redis object cache?

A: Redis stores the data in specific data types, whereas Memcached only stores data as strings. Redis reduces network overhead because of the data types, speeding up the scenarios and reducing the network I/O counts and data sizes.

Share your opinion in the comment section. COMMENT NOW

Share This Article

Customer Review at

“Beautifully optimized hosting for WordPress and Magento”

Arda Burak [Agency Owner]

Danish Naseer

Danish Naseer is a WordPress Community Manager at Cloudways. He is passionate about designing, developing, and engaging with people to help them. He also actively participates in the community to share his knowledge. Besides that, he loves to watch documentaries, traveling and spending time with family. You can contact him at [email protected]

×

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

Thankyou for Subscribing Us!

×

Webinar: How to Get 100% Scores on Core Web Vitals

Join Joe Williams & Aleksandar Savkovic on 29th of March, 2021.

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!