Picsum ID: 1003

How to Set Up Redis Object Cache for WordPress in 5 Minutes

Table of Contents
  1. Why Redis?
  2. Installation
  3. WordPress Plugin Setup

Why Redis?

Redis is an in-memory data structure store that can be used as a database cache for WordPress. It stores the results of database queries in RAM, so your site does not have to query the database on every page load. The result: your site loads 10-100x faster for returning visitors.

Redis dashboard
Redis hits vs misses — the cache is doing its job

Installation

# Install Redis server
sudo apt install redis-server

# Install PHP Redis extension
sudo apt install php-redis

# Configure Redis for WordPress
sudo sed -i "s/# maxmemory /maxmemory 32mb/" /etc/redis/redis.conf
sudo sed -i "s/# maxmemory-policy noeviction/maxmemory-policy allkeys-lru/" /etc/redis/redis.conf

# Restart services
sudo systemctl restart redis-server php8.3-fpm

# Verify
redis-cli PING
# Should return: PONG

WordPress Plugin Setup

  1. Install “Redis Object Cache” plugin by Till Krüss
  2. Activate the plugin
  3. Go to Settings > Redis
  4. Click “Enable Object Cache”

Redis turned my WordPress site from “slow and clunky” to “scary fast.” The difference was night and day.

21 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *