In this tutorial, we’ll show you how to enable Redis Object Cache in WordPress using different methods and caching plugins that support object cache.
Object caching in WordPress significantly enhances website performance by reducing the number of queries to the database, as it stores results from prior queries. This means faster page load times and a better user experience.
Before we begin, please make sure that Redis is activated on your cPanel account as shown in this article, and have the socket path handy.
How to Enable Redis Object Cache in WordPress using the LiteSpeed Cache plugin
1) Log into your WordPress Admin Dashboard and navigate to the LiteSpeed Cache ->Â Cache -> Object tab.
2) In the next section you will only have to modify the following:
Object Cache: ON
Method: Redis
Host: Add the socket path you got from cPanel -> Redis Object Cache section
Port: 0
Redis Database ID: enter a unique number for each individual website.
Leave everything else as it is and click the Save Changes button to apply the settings and activate Redis Object Cache. You should then see a Connection Test: Passed message
How to Enable Redis Object Cache in WordPress using the W3 Total Cache plugin
1) Log into your WordPress Admin Dashboard and navigate to the Performance -> General Settings -> Object Cache tab.
2) Enable Object Cache and select Redis from the drop-down menu then click Save all settings.
3) Navigate to the Object Cache section from the left side menu and add the socket path you got from cPanel -> Redis Object Cache in the Redis hostname field and click Test.
You should then see a “Test passed” message, to finish the setup save the setting.
4) Specify a unique number in the Redis Database ID field for each individual website.
How to Enable Redis Object Cache in WordPress using the Redis Object Cache plugin
1) Install and activate the Redis Object Cache plugin
2) Add the following lines in your wp-config.php file, make sure that you replace the WP_REDIS_PATH value with your unique path. Also
// Redis host and port define( 'WP_REDIS_SCHEME', 'unix' ); define( 'WP_REDIS_PATH', '/home/demosite/tmp/redis.sock' ); // change the prefix and database for each site to avoid cache data collisions define( 'WP_REDIS_PREFIX', 'website1' ); define( 'WP_REDIS_DATABASE', 0 ); // 0-15 // reasonable connection and read+write timeouts define( 'WP_REDIS_TIMEOUT', 1 ); define( 'WP_REDIS_READ_TIMEOUT', 1 );
3) After saving the changes in wp-config.php navigate to the WordPress Admin Area -> Settings -> Redis where you can enable Object Cache.
After this is enabled, you should see a Status: Connected confirmation. From this section, you can also disable or Flush Cache.
You have now succeeded in setting up the Redis object cache with your WordPress website hosted at ChemiCloud.