Skip to main content
Image alt
Categories
How To...PerformancePlugin

HOW TO: Add Object caching to your WordPress site with Redis

Install Redis on your server:

sudo apt-get update
sudo apt-get install redis-server php-redis

Open Redis’ configuration file:

sudo nano /etc/redis/redis.conf

…and add this lines:

maxmemory 256mb
maxmemory-policy allkeys-lru

Restart your WordPress server and the Redis server. For my server, I run this (you can change the FPM version number as appropriate):

sudo systemctl restart php7.4-fpm
sudo systemctl restart redis-server

Alternatively: If you’re running Apache instead of PHP-FPM run:

sudo systemctl restart apache2
sudo systemctl restart redis-server

Add these lines to wp-config.php (change the domain from 403page.com to your domain):

define( 'WP_REDIS_CLIENT', 'phpredis' );
define( 'WP_CACHE_KEY_SALT', '403page.com' );
define( 'WP_CACHE', true );

Install & activate the Redis Object Cache plugin so you easily manually flush the cache and view performance metrics:

All done! Enjoy a much smoother and more performant WordPress instace!