Redis Object Cache: What is it and how to connect it with WordPress

In today’s digital world, having a fast website is crucial to keeping visitors interested. One way to speed up your site is by using Redis object caching. This method helps your website quickly retrieve and show content by storing the results of database queries.

This guide will walk you through setting up a Redis Object Cache for your WordPress site. But first, let’s grasp the basics of caching and object caching in simple terms before diving into the technical stuff.

What is cache?

Cache (client-side caching) is popularly defined as the temporary storage where the data is stored and can be accessed quickly. 

Let’s take an example: Imagine your browser saving website files when you visit a site for the first time. When you return to the same site later, your browser quickly retrieves the files from its stored cache, making the website load faster.

What is object caching, and why is it important?

Object caching, or server-side caching, is performed on the website’s server, and the results of the database queries are saved on the server itself.

The importance of object caching is that it can decrease the Time to First Byte (TTFB) and accelerate loading times, leading to a more seamless user experience. Additionally, it contributes to enhancing the server’s overall health by alleviating its workload.

Redis is the most popular option for object caching, as it increases a WordPress site’s page loading speed.

Redis in place and its importance

Redis is a widely used software that helps speed up database operations, caching, and messaging. It’s important because it boosts performance, making your website run smoother for users. With Redis, you can do various tasks quickly, like adding elements to lists, updating values in hashes, or fetching data efficiently. This is super handy for applications that need instant access to data.

Plus, Redis ensures your data stays safe with features like periodic data backups and the ability to add extra functions using plugins. Overall, it’s a great tool for any website that wants to deliver a fast and reliable experience to its visitors.

Redis can persist data by periodically dumping the dataset to disk or appending commands to a disk-based log, depending on the use case. It’s also worth noting that Redis can be extended with new functionality using plugin modules.

Setting up Redis for your WordPress site

It’s better to check with your host first, as many WordPress hosting solutions offer Redis Object Caching with a quick or one-click installation option.

There is no official support for Windows; instead, Microsoft has created a Win-64 port of Redis. Therefore, it’s better to install Redis on a Linux server. Begin by installing and configuring Redis; after that, proceed with the installation of the PHP Redis extension and the Redis Object Cache plugin.

Before you start installing Redis for object caching on your Linux server, make sure you have:

  • Access as the root user with sudo permission.
  • The ability to connect to your server via SSH.

Let’s get started:

A step-by-step guide on using Redis for WordPress

Redis Object Caching How To Use It On Wordpress Site

In this step-by-step guide, we’ll walk you through the process of setting up Redis on a Linux VPS.

Let’s dive in!

Step 1: Connect to your Linux server

First, you’ll need to connect to your Linux server. Use SSH through a terminal program like PuTTY (for Windows) or Terminal (for macOS and Linux). Enter your server’s IP address and login details to connect.

ssh [username]@[ip_address]

Step 2: Update your system

Make sure your system is up-to-date before installing Redis. Run these commands to update the package lists and upgrade existing packages:

sudo apt update
sudo apt upgrade

Step 3: Install Redis

After updating, install Redis using this command:

sudo apt install redis-server

Step 4: Verify Redis installation

To ensure that Redis is running correctly, you can use the following command to check the status:

sudo systemctl status redis

If everything is set up correctly, you should see a status message indicating that Redis is active and running.

Step 5: Redis CLI

To make sure Redis is working right, you can do a simple test. Just connect to the Redis server and try some basic commands.

redis-cli ping

Step 6: Install the Redis PHP extension

Next, you need to install the Redis PHP extension on your server. You can do this using the following command:

sudo apt-get install php-redis

Configure Redis with WordPress

It is now time to configure Redis with WordPress. Check out the guide and follow the steps carefully.

Step 1: Install the Redis object cache plugin for WordPress

Navigate to your WordPress admin dashboard and install the Redis Object Cache plugin. You can find it by searching for “Redis Cache” in the Plugins > Add New section. Activate the plugin once it’s installed.

Now, you need to configure WordPress to use Redis as its object cache. Open your WordPress wp-config.php and add the following lines to the file, just before the “/* That’s all, stop editing! Happy blogging. */” line:

define( 'WP_REDIS_PREFIX', 'your_unique_string_here_' );

Make sure to replace ‘your_unique_string_here’ with a unique string to prevent conflicts with other sites using the same Redis server.

Step 3: Test the configuration

Once you’ve configured the plugin and set up the prefix (if desired), it’s time to test if Redis object caching is working correctly. You can use the “Test Redis” button in the plugin settings to check if the connection is established successfully.


At the end of this tutorial, it becomes crystal clear how Redis Object Caching is important for WordPress sites and how one can configure it with the WordPress site to accelerate website performance by storing database queries in the server cache.

Whether you are managing your business website or a suite of client sites, Redis makes everything seamless by providing faster loading times and a smoother user experience.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.