Page caching makes anonymous visits fast, but it can’t help logged-in users, shopping carts, checkouts, membership areas or the WordPress admin. For those, every request runs PHP and queries the database. On busy sites, that work adds up quickly.
A persistent object cache is how you speed up those dynamic requests. WordPress already has an object cache built in, but by default it only lasts for a single page load. Add Redis, and that cache persists between requests, so WordPress can reuse results instead of asking the database again.
On many WooCommerce stores and membership sites I’ve worked on, adding Redis was one of the most noticeable improvements: faster admin screens, quicker checkouts and less load on the database. Here’s how to set it up properly and avoid the common problems.
How WordPress object caching works
WordPress uses an internal cache API, through functions like wp_cache_get and wp_cache_set, to store data it has already loaded: options, posts, terms, user data and query results. Plugins use the same API.
Without a persistent backend, this cache is cleared at the end of every request. The next page load starts from scratch and queries the database again.
With Redis connected through an object cache drop-in, the cache lives in Redis’s memory between requests. When WordPress needs an option or a post it loaded recently, it gets it from Redis in a fraction of a millisecond instead of running a database query.
Transients also move from the database into Redis when a persistent object cache is active, which keeps the options table cleaner.
When Redis helps most
- WooCommerce stores, especially cart, checkout, My Account and the admin.
- Membership, LMS and community sites with many logged-in users.
- Busy admin areas, where editors and staff work all day.
- Sites with heavy or slow databases.
- Sites with many plugins that rely on cached data.
On a small blog where nearly all visitors are anonymous and page caching handles them, Redis makes little visible difference.
Step 1: Install Redis on the server
On Ubuntu or Debian:
The php-redis package provides the PHP extension WordPress uses to talk to Redis. Restart PHP-FPM after installing it.
Check Redis is running:
It should reply PONG.
On managed hosting, Redis is often available as an add-on or included in higher plans. Your host will provide connection details.
Step 2: Secure Redis
Redis should never be reachable from the internet. By default on most distributions, it listens only on localhost, which is what you want for a single-server setup. Check the configuration in /etc/redis/redis.conf:
If Redis runs on a separate server, restrict access with a firewall, require authentication and, ideally, use a private network. Exposed Redis instances are regularly found and abused by attackers.
Using a Unix socket instead of a TCP port is another option for single-server setups, slightly faster and limited to local processes with the right permissions.
Step 3: Connect WordPress
The most common approach is the Redis Object Cache plugin, which installs an object-cache.php drop-in in wp-content. Install and activate the plugin, then enable the object cache from its settings screen or with WP-CLI:
The status command shows whether WordPress is connected, which client it’s using and basic statistics.
Configuration goes in wp-config.php, before the line that says to stop editing:
Other plugins and hosting setups use different drop-ins and constants, so follow the documentation for the solution you choose.
Step 4: Use prefixes for multiple sites
If several WordPress sites share one Redis server, they must not share cache keys. Otherwise one site can read another site’s cached options, causing bizarre bugs, like one site showing another’s title, or worse, security problems.
Give each site a unique prefix with WP_REDIS_PREFIX, or a separate Redis database number. Prefixes are generally the cleaner choice, because Redis databases have limited numbers and some setups don’t support them well.
This is one of the most important settings, and one of the most commonly forgotten.
Step 5: Set memory limits and eviction
Redis keeps everything in memory. Without limits, it can grow until the server runs out of RAM. Set a maximum and an eviction policy in redis.conf:
- maxmemory caps Redis’s memory use. Size it based on your sites’ needs and the server’s available RAM. Many small and medium sites work well with 128 to 512 MB.
- allkeys-lru tells Redis to remove the least recently used keys when it reaches the limit. For a cache, that’s the right behaviour: old, rarely used data is dropped, frequently used data stays.
Restart Redis after changes:
Persistence
Redis can save its data to disk, through RDB snapshots or append-only files, so it survives restarts. For a pure object cache, persistence isn’t necessary. The cache rebuilds itself after a restart. Disabling persistence for a cache-only Redis instance reduces disk writes. If the same Redis serves other purposes, like queues, keep appropriate persistence.
Step 6: Monitor Redis
Check Redis health occasionally:
Useful numbers:
- used_memory_human: how much memory Redis is using.
- keyspace_hits and keyspace_misses: the hit rate. A healthy cache has far more hits than misses after it warms up.
- evicted_keys: how many keys were removed due to memory limits. Some eviction is normal. Constant heavy eviction means maxmemory is too small for your workload.
The Redis Object Cache plugin also shows statistics in the dashboard.
Measuring the impact
Before and after enabling Redis, measure:
- Query Monitor: the number of database queries and total query time on key pages, especially logged-in pages and checkout.
- Page generation time for uncached requests.
- Admin responsiveness for common tasks, like loading the orders list.
On dynamic pages, you’ll often see the number of database queries drop significantly once the cache is warm.
Troubleshooting
Changes don’t appear
If you update something directly in the database, outside WordPress functions, the cached version may still be served. Flush the cache:
Also flush after migrations, database imports and search-replace operations. Always use WordPress functions or WP-CLI to change data where possible, so the cache stays consistent.
Site shows wrong data from another site
Two sites share a Redis instance without unique prefixes. Set a unique WP_REDIS_PREFIX for each site and flush the cache.
Redis connection errors
If WordPress can’t reach Redis, the drop-in may show errors or the site may fall back to running without a persistent cache, depending on configuration. Check that Redis is running, that the host, port or socket are correct and that the PHP extension is installed and loaded.
Out of memory
If the server’s memory runs out, check whether maxmemory is set. Without it, Redis can grow without limit.
Plugins misbehaving with object cache
Occasionally, poorly written plugins assume the object cache is cleared on every request, or store huge amounts of data in it. If a plugin behaves strangely after enabling Redis, test with the cache disabled, report the problem to the developer and consider alternatives.
Slower after enabling Redis
Rare, but possible if Redis is on a distant server with high network latency, or if a plugin floods the cache with enormous values. Keep Redis close to PHP, ideally on the same server or a fast private network.
Redis and page caching together
Redis and page caching complement each other. Page caching serves anonymous visitors without running PHP at all. Redis speeds up everything that does run PHP. Use both for the best overall performance.
Redis on managed hosting
Many managed WordPress hosts include Redis or offer it as an add-on, usually with their own connection settings and drop-in. Use the host’s recommended setup rather than installing a separate plugin that conflicts with it, and ask how memory limits and eviction are configured for your plan.
Ask your host before changing anything.
Test after enabling
After turning Redis on, click through the site as an administrator, a customer and a visitor. Check carts, checkout, logins and settings changes to confirm everything updates as expected before relying on it.
Frequently asked questions
Do I need Redis for a small blog?
Usually not. Page caching handles most of a small blog’s traffic. Redis helps most on dynamic sites with logged-in users or stores.
Is Memcached as good as Redis?
Both work as persistent object caches for WordPress. Redis is more common today and has more WordPress tooling. Either is a big improvement over no persistent cache.
Does Redis replace page caching?
No. They solve different problems. Use both on busy sites.
Is it safe to flush the object cache?
Yes. It simply clears cached data, which WordPress rebuilds as needed. The site may be slightly slower for a moment while the cache warms up.
Final thoughts
A persistent object cache is one of the most effective ways to speed up the dynamic parts of WordPress. Install Redis securely, connect it with a reliable drop-in, give every site a unique prefix, set memory limits with an LRU eviction policy and monitor hit rates and evictions. Flush the cache after direct database changes, and pair Redis with good page caching. Your logged-in users, customers and editors will feel the difference.




