Free Support via:  +31 (0)20 796 9999

How to implement Redis in WordPress?

HINT: If you have a CMS hosting account (WordPress Performance, Magento Business, Joomla Express, Drupal Express, etc.), Combell will automatically choose the best caching method for you and configure it. You do not need to go through this procedure.

REDIS is the preferred method for caching WordPress if the backend and/or the frontend are slow

To implement REDIS in WordPress follow this tutorial:

  1. First make sure you Activate Redis caching from control panel
  2. Log into the backend of WordPress
  3. Install the following plugin: Redis Object Cache (https://wordpress.org/plugins/redis-cache/other_notes/)
  4. Activate the plugin but do not yet click on the “Enable Object Cache” button in the settings section of the plugin control.Now, as you see, this plugin has a settings screen, but you can not enter the IP address and port of your REDIS. Therefore, we should add the following to the wp-config.php via ssh:
    /**
    * REDIS config
    */
    
    define('WP_REDIS_HOST', '176.62.167.157');
    define('WP_REDIS_PORT', '10039');
    define('WP_REDIS_PASSWORD', 'password');
    define('WP_REDIS_MAXTTL', '86400');

    You are adding this block of code just above this line:

    /* That's all, stop editing! Happy blogging. */
  5. Now back in the Settings section of your WordPress plugin, click on the “Enable Object Cache” button.
    Now your Redis should work.

Checking Redis

Then check if the Redis Cache is being correctly filled. This is done as follows via the Redis-CLI:

Execute this command:

redis-cli -h redisipadress -p redisportnumber

Example:

redis-cli -h 250.250.250.1 -p 10000

This is what will appear

250.250.250.1:10000>

Now enter the word “AUTH” followed by the password of the Redis instance and press enter. This looks like this:

250.250.250.1:10000> AUTH ***************

You should now get an “OK” back. Respond with executing this command: “keys *” like so:

250.250.250.1:10000> keys *

If Redis is configured properly, you see an output similar to the following:

1) "zc:k:f01_B95179DADADD876876ADDaD87630E9E"
2) "zc:ti:f01_BLOCK_SLIDE2"
3) "zc:k:f01_Zend_LocaleC_nl_NL_country_MR"
4) "zc:ti:f01_BLOCK_CATEGORY_ABOVE_EMPTY_COLLECTION"
5) "zc:k:f01_6ADDaDA9B2A0BB12371C0A5FB79E"
6) "zc:k:f01_CMS_BLOCK_BLOCK_LEFT_TOP_1_1"
7) "zc:k:f01_Zend_LocaleC_sv_SE_language_sv"
Updated on 1 March 2023

Was this article helpful?

Related Articles