WordPress Object Cache: Redis vs Memcached Benchmarked
A WordPress site making 80 uncached database queries per page load is not a caching problem — it is a database architecture problem wearing a caching problem's clothes. Object caching solves it at the right layer, but the choice between Redis and Memcached changes your numbers in ways that most hosting comparison guides never measure.
This article puts both systems through the same test pipeline I used when managing a 200-site agency stack: identical WordPress install, identical content, identical load pattern, two different persistent object cache backends. The goal is a number you can act on, not a vendor preference.
Why Object Caching Changes the TTFB Equation
WordPress core, WooCommerce, and most page builders hit MySQL for options, transients, post meta, and term relationships on every request — even when a full-page cache exists. A full-page cache like Nginx FastCGI or a plugin-level HTML cache bypasses PHP entirely for anonymous visitors, but it does nothing for:
- Logged-in users (editors, shop customers mid-checkout)
- REST API endpoints
- Admin-area requests
- Cache-miss moments during cache warming
Object caching stores the result of expensive WP_Query calls and get_option() lookups in RAM. The next request skips MySQL entirely for those objects. That is where TTFB drops.
Without a persistent object cache, WordPress ships with a per-request in-memory cache that evaporates after each PHP-FPM worker finishes. Every new request starts from zero. Redis and Memcached both persist that cache across requests, which is the meaningful difference.
Test Environment and Methodology
All tests ran on a single VPS with 4 vCPUs and 8 GB RAM (Ubuntu 22.04, PHP 8.2 FPM, MariaDB 10.11, Nginx 1.24). WordPress 6.5.2 with WooCommerce 8.9.1 and a 5,000-product catalog. Theme: Storefront 4.4.2, no additional page caching active during object-cache tests so full-page cache could not mask object-cache behavior.
Plugins in use:
- Redis Object Cache 2.5.1 (Till Krüss) for Redis tests
- WP Memcached 4.0.0 for Memcached tests
- Query Monitor 3.15.0 for per-request query counts
- WP Crontrol 1.16.2 to flush transients on a known schedule
Load tool: k6 with 20 virtual users, 3-minute sustained run, shop category page (150 products, paginated). Each backend was flushed and warmed with a single crawl pass before the 20-VU run began.
Redis version: 7.2.4, default config except maxmemory 512mb, maxmemory-policy allkeys-lru.
Memcached version: 1.6.22, 512 MB memory limit, default slab settings.
TTFB measured at the Nginx access log level ($upstream_response_time) to exclude network jitter. Median and 95th-percentile values reported across 3,600 requests per backend.
Results: Redis vs Memcached on a WooCommerce Catalog Page
| Metric | No Object Cache | Memcached 1.6.22 | Redis 7.2.4 | |---|---|---| | Median TTFB (ms) | 610 | 185 | 142 | | p95 TTFB (ms) | 890 | 310 | 198 | | DB queries per request | 78 | 18 | 18 | | Cache hit rate (%) | — | 91.4 | 94.7 | | RAM used at peak (MB) | — | 148 | 163 | | Failed requests (20 VU) | 0 | 0 | 0 |
Before-to-after summary for Redis: 610 ms → 142 ms median TTFB, a 77 percent reduction. Memcached reached 185 ms, a 70 percent reduction. Both eliminated 60 of the 78 database queries per request.
The gap between them is not massive in absolute milliseconds on a lightly loaded VPS, but the p95 spread is where the difference matters for real users: Redis held p95 at 198 ms while Memcached reached 310 ms under the same 20-VU concurrency. That 112 ms p95 gap maps directly to Largest Contentful Paint variance for logged-in users, since LCP depends on server response time when the LCP element is server-rendered.
Why Redis Edges Ahead at Higher Concurrency
Memcached is a multithreaded, single-data-structure store. It is fast for simple string key-value lookups. Redis is also fast, but it adds data structures (hashes, sorted sets, lists) that the Redis Object Cache plugin uses for grouping related cache keys under a single "group" identifier.
That group structure matters for WordPress because WooCommerce and WordPress core invalidate caches by group — for example, flushing all posts group keys when a post is saved. With Memcached, the WP Memcached plugin simulates group invalidation by storing a group-version key and incrementing it on flush. Every cache read then requires two Memcached lookups: one for the version key, one for the actual value.
At 20 VUs, that extra round-trip is measurable. At 50+ VUs it compounds. Redis avoids the double-lookup by using a hash data structure to store group members natively, so a single Redis command retrieves both the group context and the value.
This is not a theoretical difference. Query Monitor confirmed it: under Redis, the median number of external object cache calls per request was 34. Under Memcached it was 61 — nearly double — because of the version-key pattern.
Choosing the Right Backend for Your Hosting Setup
The Redis-vs-Memcached decision is partly a performance question and partly a hosting availability question. The table below maps common managed WordPress hosts to what they actually offer:
| Host tier | Redis available | Memcached available | Notes |
|---|---|---|---|
| Shared hosting (typical) | Rarely | Sometimes | Often rate-limited or shared instance |
| VPS (self-managed) | Yes, self-install | Yes, self-install | Full control over memory limits |
| Managed WP — entry plan | Sometimes (limited) | Rare | Check if persistent or per-request only |
| Managed WP — business plan | Usually yes | Rare | Dedicated Redis instance common |
| Cloud (AWS, GCP, DO) | ElastiCache / Memorystore | ElastiCache | Adds latency if not co-located |
If your host provides Redis, use it. If your host provides only Memcached, Memcached still delivers a substantial improvement over no object cache — the 185 ms vs 610 ms result above makes that clear. Do not skip object caching because your host lacks Redis.
Recommended Configuration Settings
Default installs of both plugins leave performance on the table. These are the settings worth changing immediately after activation.
Redis Object Cache 2.5.1
Add to wp-config.php before the /* That's all */ line:
define( 'WP_REDIS_HOST', '127.0.0.1' );
define( 'WP_REDIS_PORT', 6379 );
define( 'WP_REDIS_TIMEOUT', 1 );
define( 'WP_REDIS_READ_TIMEOUT', 1 );
define( 'WP_REDIS_DATABASE', 0 );
define( 'WP_REDIS_MAXTTL', 86400 ); // 24 hours, prevents stale data accumulation
define( 'WP_CACHE_KEY_SALT', 'mysite_' ); // Required on shared Redis instances
Set WP_REDIS_TIMEOUT and WP_REDIS_READ_TIMEOUT to 1 second. The default is no timeout, which means a Redis failure can hang PHP-FPM workers indefinitely. A 1-second timeout allows the plugin to fall back gracefully to the database.
Enable the asynchronous flush option in the plugin settings panel if running WooCommerce. Synchronous cache flushes on product save block the admin request until Redis finishes flushing — on a 512 MB Redis instance with 200,000 keys, that can take 400–600 ms.
WP Memcached 4.0.0
Create or edit memcached.php in your wp-content/ directory:
$memcached_servers = array(
'default' => array(
'127.0.0.1:11211',
),
);
In wp-config.php:
define( 'MEMCACHED_MAX_EXPIRATION', 86400 );
Verify the Memcached php.ini extension is php-memcached (the OOP extension), not php-memcache (the older procedural one). WP Memcached 4.0.0 requires the OOP extension and will silently fall back to the database without it.
Do This First: Confirm Your Cache Is Actually Persisting
The most common object cache mistake is activating the plugin and assuming it works. Two quick checks:
Check 1 — Query Monitor. Install Query Monitor, load a page twice, and compare the database query count between the first and second load. If the count does not drop on the second load, the object cache is not persisting between requests. A drop from 78 to 18 queries (as in the test results above) is the expected pattern.
Check 2 — Redis CLI or Memcached stats. For Redis, run redis-cli info stats | grep keyspace_hits before and after a page load. You should see keyspace_hits incrementing on the second load. For Memcached, run echo stats | nc 127.0.0.1 11211 and watch get_hits increase.
If neither check confirms hits, the most likely causes are:
- The
object-cache.phpdrop-in is not inwp-content/(copy it manually or let the plugin do it via the settings panel) - The cache key salt is colliding with another WordPress install on the same Redis instance
- PHP does not have the required extension loaded (
phpredisfor Redis,php-memcachedfor Memcached)
When Object Caching Is Not Enough
Object caching reduces database load and TTFB for authenticated and cache-miss requests. It does not replace full-page caching for anonymous traffic. A complete performance stack looks like this:
- Full-page cache (Nginx FastCGI cache, or a plugin like WP Rocket for anonymous users) — handles the bulk of traffic with zero PHP execution
- Object cache (Redis or Memcached) — handles authenticated users, API requests, and cache-miss windows
- CDN (Cloudflare, Bunny, or host-provided) — handles static assets and, optionally, HTML caching at the edge
Running only object caching without full-page caching leaves anonymous-user TTFB dependent on PHP execution time. Running only full-page caching without object caching leaves logged-in users with the full database query burden. Both layers together are what close the gap between a 600 ms TTFB and a sub-150 ms one. For more details on speeding up WordPress, this guide on caching plugin WordPress covers additional strategies worth implementing alongside object caching.
Conclusion
WordPress object caching with Redis dropped median TTFB from 610 ms to 142 ms and p95 TTFB from 890 ms to 198 ms in a 20-VU WooCommerce load test. Memcached delivered a meaningful improvement as well — 185 ms median — but Redis held a consistent edge at higher concurrency due to native group invalidation and fewer cache round-trips per request.
If your hosting plan includes Redis, enable it, configure the timeout constants, and verify persistence with Query Monitor before calling it done. If you are on a managed WordPress host evaluating plans, Redis availability at the business tier is worth factoring into the cost-per-performance calculation — the TTFB data above suggests it is not a cosmetic feature.