What Is Object Cache—and How Does It Differ from Page Cache?
Developers new to WordPress performance often conflate two distinct caching layers. Understanding the difference is the first step toward deploying the right tool for each job.
Page cache captures the fully rendered HTML output of a URL and serves it to subsequent visitors without touching PHP or the database at all. Tools like WP Rocket, W3 Total Cache, or a reverse proxy such as Nginx FastCGI cache operate at this layer.
Object cache operates one level deeper. It stores the result of individual PHP operations—database query results, transients, option values, user meta—in fast key-value storage so that WordPress can skip redundant work within a single request and across requests. Without a persistent object cache backend, WordPress uses a non-persistent, in-memory cache that lives only for the duration of one PHP process and is discarded immediately after the response is sent.
Redis plugs into WordPress’s native WP_Object_Cache class via a drop-in file (wp-content/object-cache.php). Every cache read and write that WordPress makes internally is then routed to Redis instead of being thrown away at the end of the request.
| Cache Layer | What It Stores | Common Tool |
|---|---|---|
| Page cache | Full rendered HTML per URL | WP Rocket, Nginx FastCGI, Varnish |
| Object cache | DB query results, transients, option rows, user/post meta | Redis (via Redis Object Cache plugin), Memcached |
| Bytecode cache | Compiled PHP opcodes | OPcache (built into PHP 7+) |
| CDN / edge cache | Static assets, cached HTML at the edge | Cloudflare, Fastly, BunnyCDN |
Why WooCommerce Sites Benefit Most from Redis Object Cache
Standard informational WordPress sites often see modest gains from object caching because page cache handles the bulk of anonymous traffic. WooCommerce changes the equation significantly for three reasons.
Repeated Database Queries
Product pages, category archives, and search results trigger dozens of database queries per request—product meta, pricing rules, inventory counts, attribute terms. Redis allows those results to be reused across requests without re-querying MySQL or MariaDB on every page load.
Session and Cart Data
WooCommerce stores cart state, checkout tokens, and customer sessions as WordPress transients backed by the wp_options table by default. On high-traffic stores this creates lock contention. Redis moves that I/O off the relational database entirely.
Transient Explosion
Plugins—especially shipping rate calculators, currency switchers, and tax providers—cache their results as transients. Without a persistent object cache, these transients are written to wp_options and accumulate as autoloaded rows that inflate every page’s bootstrap cost. Redis absorbs all of that instead.
Vilee LLC combines deep technical expertise in WordPress/WooCommerce development with AI-powered automation to operate 520+ profitable online businesses at scale.
Setting Up Redis Object Cache for WordPress
The following steps assume a Linux server (Ubuntu/Debian) with PHP-FPM and a self-managed or cloud Redis instance. For managed hosting, verify that your plan exposes a Redis socket or TCP endpoint before proceeding.
Step 1: Install Redis Server
On Ubuntu/Debian:
sudo apt update
sudo apt install redis-server
sudo systemctl enable --now redis-server
Confirm Redis is running:
redis-cli ping
# Expected output: PONG
Step 2: Install the PHP Redis Extension
The Redis Object Cache plugin supports both the phpredis C extension (faster) and the pure-PHP Predis library. Install the extension:
sudo apt install php-redis
sudo systemctl restart php8.2-fpm # adjust version as needed
Step 3: Install the Redis Object Cache Plugin
Install Redis Object Cache by Till Krüss from the WordPress plugin directory, or via WP-CLI:
wp plugin install redis-cache --activate
Step 4: Add Defines to wp-config.php
Open wp-config.php and add the following above the line that reads /* That's all, stop editing! */:
// Redis connection
define( 'WP_REDIS_HOST', '127.0.0.1' );
define( 'WP_REDIS_PORT', 6379 );
define( 'WP_REDIS_DATABASE', 0 ); // see multi-site section below
define( 'WP_REDIS_TIMEOUT', 1 );
define( 'WP_REDIS_READ_TIMEOUT', 1 );
// Unique cache key prefix for this site
define( 'WP_CACHE_KEY_SALT', 'mysite_prod_' );
If your Redis server requires a password (strongly recommended in production), add:
define( 'WP_REDIS_PASSWORD', 'your-strong-password' );
Step 5: Enable the Drop-in
From the WordPress admin go to Settings → Redis and click Enable Object Cache. This copies object-cache.php into wp-content/. Alternatively, use WP-CLI:
wp redis enable
Critical Best Practice: Multi-Site Key Isolation
This is the most commonly skipped step—and the one most likely to cause data leakage or corrupted cache reads in shared hosting or multi-tenant environments.
When multiple WordPress installations share the same Redis instance, their cache keys can collide. If site-a.com and site-b.com both store a key named options:alloptions, whichever site writes last overwrites the other’s cached data.
There are two isolation mechanisms and you should apply both:
Dedicated Redis DB Number
Redis supports up to 16 logical databases (0–15) within a single instance. Assign each WordPress site a unique database number:
// Site A — wp-config.php
define( 'WP_REDIS_DATABASE', 1 );
// Site B — wp-config.php
define( 'WP_REDIS_DATABASE', 2 );
Note: Redis Cluster does not support multiple databases. On Cluster deployments rely exclusively on the key salt approach below.
Unique WP_CACHE_KEY_SALT
The cache key salt is prepended to every key the plugin writes. Make it unique per environment and per site:
// Site A production
define( 'WP_CACHE_KEY_SALT', 'sitea_prod_v1_' );
// Site A staging (same Redis, different salt)
define( 'WP_CACHE_KEY_SALT', 'sitea_staging_v1_' );
// Site B production
define( 'WP_CACHE_KEY_SALT', 'siteb_prod_v1_' );
Using both the database number and a unique salt provides defense in depth. If a misconfiguration causes the wrong DB number to be used, the salt still prevents collisions. See our services for managed WordPress infrastructure that handles this automatically across all client environments.
Setting Eviction Policy and maxmemory
Redis is an in-memory store. Without a memory limit and an eviction policy, it will consume all available RAM and either crash or refuse writes. Configure both in /etc/redis/redis.conf:
maxmemory 256mb
maxmemory-policy allkeys-lru
allkeys-lru evicts the least-recently-used keys when the memory limit is reached—appropriate for a pure cache workload. If you also use Redis for queues or locks, use volatile-lru instead to protect keys that have no TTL set.
Reload the configuration without a restart:
redis-cli CONFIG SET maxmemory 268435456
redis-cli CONFIG SET maxmemory-policy allkeys-lru
Verifying Redis Object Cache Is Working
Three verification methods in order of reliability:
1. WordPress Admin Panel. Navigate to Settings → Redis. The status badge should read Connected and display hit/miss statistics after a few page loads.
2. WP-CLI. Run wp redis status to see connection details, client library, and current hit rate.
3. redis-cli monitor. Run redis-cli monitor in one terminal while loading a WordPress page in another. You should see a stream of GET and SET commands keyed with your cache salt prefix, confirming the drop-in is routing calls to Redis.
Setup Checklist
- Redis server installed and running —
redis-cli pingreturnsPONG - PHP Redis extension installed —
php -m | grep redisshows the module - Redis Object Cache plugin installed and activated
- WP_REDIS_HOST, WP_REDIS_PORT defined in
wp-config.php - WP_REDIS_DATABASE set to a unique number per site on shared instances
- WP_CACHE_KEY_SALT set to a unique string per site and per environment
- WP_REDIS_PASSWORD set if Redis auth is enabled (it should be)
- object-cache.php drop-in enabled — present in
wp-content/ - maxmemory configured in
redis.conf - maxmemory-policy set to
allkeys-lruorvolatile-lru - Cache status verified via admin panel or
wp redis status - Staging environment uses a different DB number and salt than production
Ready to Reduce Database Load?
Redis object caching eliminates entire categories of redundant database queries, absorbs transient writes that bloat wp_options, and moves cart and session I/O off your relational database entirely.
On shared Redis instances, the multi-site isolation steps are not optional—they are production requirements. Get the salt and DB number right from the start and you avoid cache corruption bugs that are notoriously hard to diagnose after the fact.
Contact us to discuss how Vilee LLC architects Redis caching, cache invalidation strategies, and full-stack WordPress performance for high-traffic WooCommerce stores.
Frequently Asked Questions
Does Redis object cache replace page cache for WordPress?
No. Redis object cache and page cache operate at different layers. Page cache serves fully rendered HTML to anonymous visitors without running PHP. Object cache stores PHP-level data (query results, transients, options) and helps all request types—including logged-in users and WooCommerce cart sessions—that bypass page cache entirely. You should run both layers simultaneously for maximum performance.
What happens if Redis goes down while object caching is active?
The Redis Object Cache plugin includes graceful degradation. When it cannot connect to Redis, WordPress falls back to its built-in non-persistent in-memory cache for the duration of the request. The site remains functional but loses the performance benefit of persistent caching. Set WP_REDIS_TIMEOUT and WP_REDIS_READ_TIMEOUT to low values (1–2 seconds) so failed connection attempts do not stall PHP workers.
How do I flush the Redis cache after a WordPress update or plugin change?
From the WordPress admin go to Settings → Redis and click Flush Cache. Via WP-CLI, run wp cache flush—this respects the configured key salt and only flushes keys belonging to the current site, which is why the unique salt matters on shared Redis instances. You can also flush a specific Redis database with redis-cli -n
