Boost WordPress performance with redis object caching

Optimizing database queries is a must with WordPress as it rely a lot on MySQL/MariaDB. That’s where Redis, an in-memory data structure store, used as a database, cache and message broker, comes into play. Redis PHP extension is available on all our servers with PHP >= 7.4. Follow this guide to quickly improve your WordPress performance in 60 seconds.

Redis Object Cache plugin

Install and activate Redis Object Caching plugin from WordPress dashboard or with WordPress cli.

					[www@web blog]$ wp plugin install redis-cache
Installing Redis Object Cache (2.0.15)
Téléchargement du paquet d'installation depuis
Décompression de l'archive de l'extension...
Installation de l'extension...
L'extension a bien été installée.
Success: Installed 1 of 1 plugins.
[www@web blog]$ wp plugin activate redis-cache
Plugin 'redis-cache' activated.
Success: Activated 1 of 1 plugins.
[www@web blog]$ wp redis enable
Success: Object cache enabled.

WordPress configurations

Enable WordPress persistent caching with a unique key.

					[www@web blog]# diff -u wp-config.php 
--- wp-config.php	2020-06-08 18:03:59.830519701 -0400
+++	2020-11-09 10:16:25.282854737 -0500
@@ -80,6 +80,8 @@
 define('WP_DEBUG', false);
+define('WP_CACHE', true);
+define('WP_CACHE_KEY_SALT', '');
 /* That's all, stop editing! Happy blogging. */

Plugin status

Redis Object Cache plugin provides a status page to ensure caching is in place. We can also use WordPress cli to verify the plugin status and diagnose issues.

					[www@web blog]# wp redis status
Status: Connected
Client: PhpRedis (5.3.2)
Drop-in: Valid
Disabled: No
Filesystem: Working
Ping: 1
Errors: []
PhpRedis: 5.3.2
Predis: Not loaded
Credis: Not loaded
PHP Version: 7.3.0
Plugin Version: 2.0.15
Redis Version: 5.0.9
Multisite: No
Global Prefix: "wwwp_"
Blog Prefix: "wwwwp_"
Now that Redis Object Caching plugin is enabled, your WordPress database will be queried much less often and retrieving content from the cache will be a lot faster.