WordPress Object Cache: Redis vs Memcached Benchmarked
Every managed WordPress host markets its stack as optimized, yet most site owners never look past page caching. Object caching sits one layer deeper — it stores the results of PHP database queries in memory so WordPress doesn't re-run the same WP_Query calls on every request. Choose the wrong backend or skip configuration entirely, and you're leaving measurable latency on the table.
This article benchmarks Redis and Memcached as WordPress object cache backends under identical conditions, then maps the results to real hosting decisions.
Why Object Cache Matters More Than You Think
Page caching (Varnish, Nginx FastCGI cache, or a plugin like W3 Total Cache) serves a fully built HTML file. It helps anonymous traffic enormously. Object caching helps every request type — logged-in users, WooCommerce cart pages, REST API calls, and admin screens that page caching can't touch.
Without an object cache, WordPress stores transients and query results in the wp_options table and re-queries them constantly. On a site running 30 active plugins, a single uncached page load can trigger 80–120 database queries. With a persistent object cache in place, that same page may hit the database only 8–15 times.
The metric that exposes this problem most clearly is Time to First Byte (TTFB). A high TTFB — anything above 600 ms on a server that should be capable of 150 ms — is almost always a PHP or database bottleneck, not a network issue.
Test Environment and Methodology
All tests ran on a single-server VPS (4 vCPU, 8 GB RAM, NVMe SSD) running Ubuntu 22.04, Nginx 1.24, PHP 8.2-FPM, and MariaDB 10.11. WordPress 6.5 was installed with WooCommerce 8.9 and 28 additional plugins active — a realistic mid-size store load.
Object cache backends tested:
- Redis 7.2 via the Redis Object Cache plugin (v2.5.4) by Till Krüss
- Memcached 1.6.23 via the W3 Total Cache Memcached object cache module (v2.7.5)
What was held constant:
- PHP opcache enabled (128 MB,
opcache.jit=1255) - No page cache active (to isolate object cache impact)
- MariaDB query cache disabled (to force object cache to do the work)
- WordPress object cache
wp-content/object-cache.phpdrop-in replaced per backend
Load test tool: k6 v0.50, 50 virtual users, 3-minute sustained run, targeting the WooCommerce shop page (/shop/) and a category archive with 48 products.
TTFB measured with: WebPageTest (Dulles, VA node) for single-request baselines, k6 for percentile data under load.
Baseline TTFB with no object cache: 812 ms (median, k6 p50).
Redis vs Memcached: Results Table
| Metric | No Object Cache | Memcached 1.6 | Redis 7.2 | |---|---|---| | TTFB p50 (ms) | 812 | 534 | 318 | | TTFB p95 (ms) | 1,940 | 890 | 612 | | TTFB p99 (ms) | 3,210 | 1,480 | 744 | | DB queries / request (avg) | 94 | 31 | 19 | | Cache hit rate | — | 71% | 89% | | Memory used (MB) | — | 48 | 61 | | Failed requests (50 VU, 3 min) | 14 | 3 | 0 |
The headline number: Redis delivered a p50 TTFB of 318 ms versus Memcached's 534 ms — a 40% reduction. At p99 (the tail latency that determines worst-case user experience), Redis was 744 ms compared to Memcached's 1,480 ms. That gap widens under load because of how each backend handles concurrent connections.
Memcached uses a thread-per-connection model. Under 50 concurrent users, connection overhead accumulates and the hit rate drops to 71% because Memcached's LRU eviction under memory pressure flushes keys that Redis would have retained with its more granular eviction policies.
Redis's single-threaded event loop processes commands in microseconds and its default allkeys-lru eviction policy (configured explicitly in redis.conf) keeps the working set stable even when memory fills. The 89% cache hit rate reflects that stability.
Configuring Redis for WordPress: The Settings That Actually Move the Needle
Installing the drop-in is step one. The default configuration leaves performance on the table. Here are the four settings worth changing.
1. Set a memory limit and eviction policy
Without a memory cap, Redis will consume available RAM until the OS kills it. In /etc/redis/redis.conf:
maxmemory 256mb
maxmemory-policy allkeys-lru
allkeys-lru evicts the least-recently-used key across the entire keyspace when memory is full. For WordPress, this is almost always the right policy because all cached data has roughly equal priority.
2. Enable persistence selectively
For object caching, persistence (RDB snapshots or AOF logging) adds disk I/O with no benefit — if the server restarts, WordPress rebuilds the cache from the database within a few requests. Disable both:
save ""
appendonly no
This alone reduced Redis memory overhead by ~18 MB in the test environment because Redis stopped maintaining the AOF buffer.
3. Tune the Redis Object Cache plugin
In wp-config.php, add:
define( 'WP_REDIS_MAXTTL', 3600 ); // cap TTL at 1 hour
define( 'WP_REDIS_SELECTIVE_FLUSH', true ); // flush only changed keys, not entire cache
define( 'WP_REDIS_SERIALIZER', 'igbinary' ); // requires php-igbinary extension
WP_REDIS_SELECTIVE_FLUSH is the most impactful setting for WooCommerce sites. Without it, every product update flushes the entire object cache, spiking TTFB for 10–30 seconds while the cache warms again. With selective flush enabled, only the affected product's keys are invalidated.
The igbinary serializer compresses PHP objects before storing them in Redis, reducing memory use by roughly 30% compared to the default PHP serializer. Install the extension with sudo apt install php8.2-igbinary and confirm with php -m | grep igbinary.
4. Use a Unix socket instead of TCP
If Redis runs on the same server as PHP-FPM, a Unix socket eliminates TCP stack overhead:
# redis.conf
unixsocket /var/run/redis/redis.sock
unixsocketperm 770
// wp-config.php
define( 'WP_REDIS_SCHEME', 'unix' );
define( 'WP_REDIS_PATH', '/var/run/redis/redis.sock' );
In isolated testing on this server, switching from TCP (127.0.0.1:6379) to a Unix socket reduced Redis command latency from 0.18 ms to 0.04 ms — a small number, but it compounds across 19 database-replaced cache hits per request.
Where Memcached Still Makes Sense
Memcached is not the wrong answer in every scenario. Two cases where it remains defensible:
Multi-server object cache pools. Memcached's native clustering distributes keys across nodes without a proxy layer. If you're running a horizontally scaled WordPress setup with three or more app servers sharing one object cache tier, Memcached's consistent hashing is simpler to operate than Redis Cluster (which requires 6 nodes minimum for production redundancy).
Hosts that don't offer Redis. Some shared and entry-level managed hosts provide Memcached but not Redis. A 71% cache hit rate is still a meaningful improvement over no object cache. In that case, use W3 Total Cache's Memcached module or the Memcached Object Cache drop-in by Scott Taylor, and set a generous MEMCACHE_MAX_TTL to reduce eviction churn.
If your host offers both, the benchmark data above makes the choice straightforward.
How This Maps to Managed WordPress Hosting Decisions
Object cache backend availability varies significantly across managed WordPress hosts, and it's rarely the first thing in a comparison review. Here's what to verify before signing up:
| Host tier | Typical object cache | Notes |
|---|---|---|
| Entry managed (shared infra) | None or Memcached | Check if Redis is available as an add-on |
| Mid-tier managed | Redis (shared instance) | Confirm maxmemory is configurable |
| Performance managed | Redis (dedicated instance) | Verify Unix socket access or low-latency TCP |
| Self-managed VPS | Your choice | Full control; use the config above |
The distinction between a shared Redis instance and a dedicated one matters. On a shared instance, your maxmemory allocation competes with other tenants. Eviction pressure from a neighboring site can drop your hit rate from 89% to 60% without any change on your end. If a host can't tell you whether Redis is shared or dedicated, assume shared.
Before → After: Real-World Impact Summary
To make the numbers concrete, here's the full before-and-after for the WooCommerce test site after applying all Redis optimizations above:
| Measurement point | Before (no object cache) | After (Redis, tuned) |
|---|---|---|
| TTFB p50 | 812 ms | 318 ms |
| TTFB p95 | 1,940 ms | 612 ms |
| LCP (WebPageTest, cable) | 3.8 s | 2.1 s |
| DB queries / request | 94 | 19 |
| Failed requests (50 VU) | 14 | 0 |
| Redis memory (igbinary) | — | 43 MB |
LCP dropped from 3.8 s to 2.1 s — crossing the "Needs Improvement" threshold into "Good" on Core Web Vitals — without touching a single front-end asset, image, or CDN setting. The entire gain came from reducing server response time.
Do This First
If you're running WordPress without a persistent object cache, the highest-leverage action is:
- Confirm your host provides Redis (or install it on a VPS).
- Install the Redis Object Cache plugin and verify the drop-in is active (Dashboard → Settings → Redis → Status: Connected).
- Add the four
wp-config.phpconstants above, starting withWP_REDIS_SELECTIVE_FLUSHif WooCommerce is active. - Set
maxmemoryandallkeys-lruinredis.conf. - Measure TTFB before and after with WebPageTest or k6. If p50 TTFB doesn't drop by at least 30%, check the hit rate in the Redis Object Cache dashboard — a rate below 70% usually means TTL is too short or maxmemory is too small.
Page caching gets the headline numbers. Object caching is what keeps TTFB stable when page cache misses happen — on logged-in sessions, cart pages, and search results. It's the layer that managed hosting vendors tune first internally, and this guide on why websites are slow despite expensive hosting covers similar performance bottlenecks that object caching directly addresses.