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:
- First make sure you Activate Redis caching from control panel
- Log into the backend of WordPress
- Install the following plugin: Redis Object Cache (https://wordpress.org/plugins/redis-cache/other_notes/)
- 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', '126.96.36.199'); 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. */
- Now back in the Settings section of your WordPress plugin, click on the “Enable Object Cache” button.
Now your Redis should work.
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
redis-cli -h 250.250.250.1 -p 10000
This is what will appear
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"