Welcome to HowToShipIt — practical how-to guides for developers: code, AI tools, and servers, explained step by step.

How to Set Up WordPress Redis Cache: Faster Dynamic Pages (2026)

If your WordPress site feels slow for logged-in users even though you already have page caching, the bottleneck is probably not the page — it is the database. Every dynamic request rebuilds the same options, post meta, and user data from MySQL, over and over. A WordPress Redis cache fixes exactly that: it stores those repeated database results in memory so WordPress can skip the queries entirely. This guide walks you through installing Redis on a VPS, locking it down, connecting it with the free Redis Object Cache plugin, and proving it is actually working. Verified October 2026.

What a WordPress Redis cache actually is

WordPress has a built-in object cache, but by default it is non-persistent: it lives only for the duration of a single request and then disappears. That means the next visitor triggers the same database queries all over again. A persistent object cache changes that by storing cached objects somewhere that survives between requests — in this case, in Redis, an in-memory data store.

It is important to understand what layer you are fixing, because WordPress has three different caches that people constantly confuse:

  • Page cache stores finished HTML pages and serves them without running PHP at all. Great for anonymous visitors; useless for logged-in users, carts, and dashboards.
  • OPcache stores compiled PHP bytecode so PHP does not re-parse your files on every request. It speeds up PHP execution, not database access.
  • Object cache stores the results of database queries and expensive computations — options, post objects, user meta, transients — so repeat requests skip the database.

Redis sits in that third layer. It will not make your cached homepage faster (page cache already handles that), but it will make wp-admin, WooCommerce carts, membership pages, and every other dynamic page noticeably snappier, and it takes real load off MySQL under traffic spikes.

Before you start: when Redis helps, and when it does not

Redis is worth it when your site has dynamic traffic: logged-in users, WooCommerce, forums, membership content, or an admin panel that feels sluggish. It is also worth it when your database is the bottleneck — you will see that as high MySQL CPU or slow query logs full of repeated option and meta lookups.

Skip it (for now) if your site is a small brochure site whose visitors are almost all anonymous and already served by page caching — Redis adds a moving part for gains you will never notice. Also skip the self-hosted route if you are on shared hosting with no Redis available: many managed hosts offer Redis as a toggle in their panel instead, and that is the right path there. This guide assumes you have a VPS with SSH and sudo access, running Ubuntu and Nginx or Apache.

Step 1: Install Redis and the PHP extension

On Ubuntu or Debian, Redis and the PHP Redis extension are both one apt command away:

sudo apt update
sudo apt install redis-server php-redis
sudo systemctl enable --now redis-server
redis-cli ping

If the last command answers PONG, Redis is running. (On some distributions the service is called redis rather than redis-server; if the enable command fails, check with systemctl list-units | grep redis.)

Now restart PHP so it picks up the new extension:

sudo systemctl restart php8.3-fpm

Use the PHP version your server actually runs — check with php -v if you are unsure. If you run Apache with mod_php instead of PHP-FPM, restart Apache.

One note on the extension: the Redis Object Cache plugin works without php-redis because it bundles Predis, a pure-PHP client. But the native PhpRedis extension is faster, so install it anyway when you control the server.

Step 2: Lock Redis down before WordPress ever touches it

Redis has no access control by default beyond an optional password, and historically the most embarrassing Redis incidents have all been the same story: a Redis instance left listening on a public interface. Do this configuration before you connect anything. Open /etc/redis/redis.conf and set:

bind 127.0.0.1
protected-mode yes
requirepass YOUR_LONG_RANDOM_PASSWORD
maxmemory 256mb
maxmemory-policy allkeys-lru
save ""
appendonly no

What each line does:

  • bind 127.0.0.1 makes Redis listen on localhost only. Nothing outside the server can reach it.
  • protected-mode yes is the safety net: Redis refuses connections from outside localhost when no password is set.
  • requirepass adds password authentication. Generate a long random one; you will paste it into wp-config.php shortly.
  • maxmemory 256mb caps how much RAM Redis may use. 256 MB is plenty for most single WordPress sites; raise it on busy or multi-site servers.
  • maxmemory-policy allkeys-lru is the critical one. Redis’s default policy is noeviction, which means that when memory fills up, writes start failing with out-of-memory errors. For a cache, you want Redis to evict the least-recently-used keys instead.
  • save "" and appendonly no disable on-disk persistence. A cache does not need to survive a reboot — WordPress simply rebuilds it — and disabling persistence removes disk I/O from the hot path.

Then restart Redis:

sudo systemctl restart redis-server

Step 3: Connect WordPress with the Redis Object Cache plugin

WordPress does not talk to Redis on its own; it needs a bridge. The standard one is the free Redis Object Cache plugin by Till Krüss, available in the WordPress plugin directory. It supports Predis, PhpRedis, and Relay, and it works by installing an object-cache.php drop-in file into your wp-content directory. That drop-in replaces WordPress’s default in-memory object cache with one backed by Redis.

Install it from the dashboard under Plugins → Add New, or with WP-CLI:

wp plugin install redis-cache --activate

Before you enable it, add the connection details to wp-config.php, above the /* That's all, stop editing! */ line:

define( 'WP_REDIS_HOST', '127.0.0.1' );
define( 'WP_REDIS_PORT', 6379 );
define( 'WP_REDIS_PASSWORD', 'YOUR_LONG_RANDOM_PASSWORD' );
define( 'WP_REDIS_DATABASE', 0 );
define( 'WP_REDIS_TIMEOUT', 1 );
define( 'WP_REDIS_READ_TIMEOUT', 1 );
define( 'WP_REDIS_PREFIX', 'yoursite:' );

A few things worth knowing about these constants:

  • WP_REDIS_PREFIX is the current way to namespace your keys. The older WP_CACHE_KEY_SALT still works but is deprecated in favour of the prefix, so use the prefix on new setups.
  • WP_REDIS_DATABASE picks one of Redis’s numbered databases (0–15). Give each WordPress site on the same server its own database number and its own prefix — belt and braces against key collisions.
  • The timeouts are in seconds. One second each keeps a dead Redis from hanging your whole site while it waits.
  • If Redis runs on the same machine over a Unix socket instead of TCP, the plugin also supports WP_REDIS_SCHEME set to unix with WP_REDIS_PATH pointing at the socket.

Now go to Settings → Redis in wp-admin (older versions of the plugin show it under Tools → Redis) and click Enable Object Cache. If the connection details are right, the status flips to Connected and the drop-in is installed.

Step 4: Prove the cache is actually working

Do not trust a green badge alone. Run three checks:

1. The plugin status page. After some traffic, it should show a rising object count and a hit ratio. A healthy site settles at a high hit ratio after warm-up; a ratio stuck near zero means requests are not finding cached objects.

2. Watch live traffic. From SSH, run redis-cli -a 'YOUR_LONG_RANDOM_PASSWORD' monitor and load a few pages. You should see Redis receiving and serving keys in real time. If nothing appears, the drop-in is not active.

3. Compare hit and miss counters. redis-cli INFO stats shows keyspace_hits and keyspace_misses. Refresh several pages, run it again, and confirm hits climb faster than misses. For a before-and-after on database load, Query Monitor’s query count on a heavy admin page is the most convincing number you can show a client.

5 mistakes that break WordPress Redis setups

1. Leaving Redis exposed. Binding to 0.0.0.0 without a password is how Redis instances end up in breach reports. Localhost-only plus a password is non-negotiable.

2. Forgetting the eviction policy. The noeviction default means a full Redis starts rejecting writes. Set allkeys-lru and a maxmemory cap on day one.

3. Sharing a database across sites. A cache flush operates on the Redis database your site uses. If two sites share database 0, one site’s flush wipes the other’s cache too. Separate database numbers and unique prefixes per site.

4. Expecting page-cache results. Object caching does not speed up anonymous page loads that page caching already serves. Judge it on wp-admin, carts, and logged-in page times, not on a homepage speed test.

5. Forgetting to restart PHP after installing php-redis. The extension does not load until PHP-FPM (or Apache) restarts, and the plugin will silently fall back to Predis. It still works — just slower than it should be.

When to flush, and when to leave it alone

WordPress invalidates cached objects properly when content changes, so you do not need to flush on a schedule — and you should not, because a flush means every query hits the database again until the cache warms back up. Flush deliberately: after a migration, after changing Redis configuration, or when you are debugging genuinely stale content that survives a normal content update. The plugin’s admin bar menu and wp redis flush both do it in one action.

One more thing to know before you scale this up: the free plugin covers single-server setups well. If you later move to replication, sentinels, or clustering, the same plugin documents those connection modes — and there is a paid sibling, Object Cache Pro, aimed at that tier. For a single VPS, the free plugin is the right tool.

Further Reading & References

Internal reading on HowToShipIt: How to Speed Up WordPress Without Plugins, WordPress Cron Is Fake: How to Disable WP-Cron and Set Up Real Cron, and WordPress Debug.log: How to Enable It and Read What It Tells You.

Leave a Comment