Tag Archives: redis object caching

How to configure Redis Object Cache in WordPress

There are a number of plugins that permit configuring Redis as Object Cache for your WordPress website, thereby enhancing its performance. In this article, we discuss LiteSpeed Cache for WordPress, also known as LSCWP, and Redis Object Cache plugins.

Before beginning this tutorial, it is assumed that Redis has been enabled in cPanel. If not, please read this article to get started.

Also, make a note of the Redis socket path and port displayed in the cPanel >> Redis Manager Plugin.

Configuring Redis in LiteSpeed Cache for WordPress (LSCWP) plugin

If you are using Lite Speed Cache for WordPress (LSCWP) plugin, navigate to Cache settings on the left menu and select [6] Object tab.

LSCWP Object cache configuration with Redis

LSCWP Object cache configuration with Redis

Ensure settings are made as above in your setting page, i.e.

  1. Turn ON Object Cache.
  2. In the Status box below, if you have already enabled the PHP Redis module, it will show Redis Extension as Enabled. If it shows Disabled, ensure it’s enabled in cPanel >> Select PHP version for the selected PHP version.
  3. Choose Method as Redis next.
  4. The Host is the socket path you have copied from the cPanel Redis Manager plugin.
  5. Port is always 0 as you are using a Unix Socket connection, not HTTP.
  6. Redis Database ID should be unique if you have multiple WordPress or other CMS configured with the Redis instance you have for your cPanel account. i.e., for the first website, default 0 is used. On the next website, you should use it as 1 or any value up to 7 but not 0. This is to avoid potential cache conflicts. You can use up to 8 databases in total for a cPanel account.
  7. Scroll down a bit and ensure “Persistent Connection” and “Store Transients” are set to ON
  8. Click “Save Changes”
LSCWP Object cache configuration with Redis

LSCWP Object cache configuration with Redis

Once saved, you should see “Connection Test”  as passed in the Status box. If it shows failed, ensure Host is correct and is added without any spaces. If the issue persists, let us know.

For more details on LSCWP configuration, you can also check out the official page here.

Configuring Redis using the “Redis Object Cache” plugin

Once logged in as administrator to your WordPress installation, go to plugins >> Add New and search for the “Redis Object Cache” plugin. Locate the Redis Object Cache as in the screenshot below, and then click Install Now. 

Redis Object Cache plugin for WordPress

Redis Object Cache plugin for WordPress

Once installed, click Activate and you will be presented with a screen as below.

Redis Object Cache plugin activation page

Redis Object Cache plugin activation page

Before clicking “Enable Object Cache”, open wp-config.php in your favorite text editor or editor in the cPanel file manager and add these two lines just above the /* “That’s all, stop editing! Happy publishing. */ line near the end of the file.

​define( 'WP_REDIS_SCHEME', 'unix');
define( 'WP_REDIS_PATH', '/home/username/redis/redis.sock');

Replace the username with the cPanel username and save the changes.

On WordPress, on the Redis Object Cache page, click Enable Object Cache. When you see green checkmarks for Status, Drop-in, and File system, Redis is activated and running for WordPress.

There are no other configurations required to take advantage of performance improvements from Redis caching, and it works flawlessly with other caching plugins. The following options are available in the plugin interface:

  1. To view Redis caching statistics for your website, click the Metrics tab.
  2. To view configuration and debugging information in greater detail, select the Diagnostics tab.
  3. To clear the Redis cache, click the Flush Cache button.
  4. Click Disable Object Cache to disable Redis caching.

More options to add Redis to your WordPress

While the above are commonly used plugins, there are several other plugins like W3TC, WP-Redis which also do the Redis integration. If you are using a different one and need assistance or an article regarding it, mention it in the comment section below.

Conclusion

Adding Redis Object Caching to WordPress sites is beneficial in terms of performance on the website. This article sheds light on configuring Redis object cache on your WordPress website using the two most widely used plugins – LSCWP and Redis Object Cache, which undoubtedly enhances caching and performance. 

How to enable Redis Object cache to use with your website

We take customer feedback seriously and continue to add new features. You’ve been asking for “Redis Object Cache” and we’ve recently completed adding this feature for you. Before we go any further, let’s see what Redis is.

What is Redis?

Redis is an in-memory data structure store that is free and open-source. It holds strings, hashes, lists, sets, and sorted sets, and serves as a key-value store as well. Redis makes it simple to store big volumes of data without degrading data transport speed. It has a passive data caching system that clears the outdated cache as fresh content is updated.

How Redis can improve your WordPress website’s performance?

By turning on Redis Cache in your WordPress Core installation, you can send the content to the client more quickly. WordPress does a lot of lookups in MySQL, which makes it very slow when there is a lot of traffic. As an in-memory structure, Redis cache can play a key role in making WordPress’s database usage more efficient. With the help of plugins, Redis stores all key-value data in memory. So, it is a quick way to cache on the server side, like WordPress. A Redis object can be used to store the cache of request outputs for a specific MySQL query. When other users have already looked at the same post or article, it will use the object cache instead of the MySQL server to serve the request. So, the server response time and site speed got better.

Let’s enable Redis Object cache to use with your website.

Quick steps:

  1. Login to cPanel
  2. Locate and click on the PHP selector in the software section.
  3. Enable the Redis PHP Extension by clicking the Redis option.
  4. Locate and Click on Redis Manager plugin in the software section to enable the Redis service.
  5. There is an option to enable or disable Redis service.

Attention: This feature is being rolled out, and it will be available for all our Shared Hosting customers shortly. If you can’t find it in the cPanel check back after a few days or open a ticket with our Support Team. 

Enable the Redis PHP Extension in the PHP Selector tool in cPanel

First, log in to cPanel then navigate through the PHP selector, and ensure the active(current) PHP version is other than the native one. If native, select a compatible PHP version first and click “Apply”. Under extensions, select Redis as in the screenshot below. Now, you should be able to use Redis, as a caching method for your website.

PHP selector in cPanel

PHP selector in cPanel

Enable Redis using the Redis Manager plugin

Note : Redis Manager is exclusive to cPanel’s new Jupiter UI theme. Verify that you are using the Jupiter theme, or select Jupiter from the Theme drop-down menu under General Information.

Enabling Redis Module in PHP is not sufficient to use the Redis Object Cache as its runs as a service. From the cPanel, you can enable Redis service via the Redis Manager plugin in the software section of cPanel. You can toggle enable or disable Redis service simply via cPanel as in the screenshot below.

Redis Manager plugin to enable redis object cache

Redis Manager plugin to enable Redis object cache

Once you clicked the “Submit” button, allow 5 to 10 minutes before you can start using Redis service with your website.

Disable Redis service using Redis Manager plugin

Simply uncheck the checkbox “Enable/Disable Redis” and click “Submit”. The service will be removed from your account in the next 5 to 10 minutes.

How to configure Redis in your website to improve performance

We have a few articles here that describe how to configure Redis with your WordPress website by using cache or dedicated plugins. The URLs are below.

How to configure Redis Object Cache in WordPress

Conclusion

Congratulations! You have learned how to enable Redis on your cPanel account.