WordPress Object Cache: Redis vs Memcached Benchmarked
A WordPress object cache sits between PHP and your database. Every time WordPress resolves a query — user roles, option rows, term counts — it can either hit MySQL again or pull the answer from memory. The difference shows up directly in TTFB.
Most performance guides stop at page caching. Object caching is the layer underneath, and it matters more on sites with logged-in users, WooCommerce sessions, or heavy taxonomy queries, where full-page cache either can't run or expires constantly. This article measures Redis and Memcached side-by-side on the same WordPress stack so you can choose based on numbers rather than marketing copy.
Why Object Cache Matters More Than Most Guides Admit
WordPress stores transients, widget data, nav menus, and dozens of option rows in the wp_options table. On a cold request, a typical WooCommerce shop page can generate 80–120 database queries. With a persistent object cache, repeated lookups resolve in microseconds from RAM instead of milliseconds from disk.
The gap is measurable. On my test stack (more on methodology below), a WooCommerce archive page with no object cache averaged 310 ms TTFB across 50 sampled requests. With Redis active, that dropped to 118 ms — a 62% reduction. Memcached brought it to 134 ms — a 57% reduction. Both are meaningful; the 16 ms gap between them is not trivial at scale.
Before explaining which to choose, here is exactly how I measured.
Test 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 MySQL 8.0. WordPress version: 6.5.3. WooCommerce: 8.9.1.
Plugins active during testing:
- WooCommerce 8.9.1 (30 products, 4 categories)
- Query Monitor 3.16.2 (for per-request query counts)
- No page cache active during object cache tests (to isolate the variable)
Redis setup: Redis 7.2, connected via predis/predis through the Redis Object Cache plugin (version 2.5.4) with WP_REDIS_MAXTTL set to 3600.
Memcached setup: Memcached 1.6.22, connected via the W3 Total Cache Memcached object cache driver (W3TC 2.7.5, all other W3TC features disabled).
Measurement tool: wrk with 10 concurrent connections, 30-second duration, five runs per configuration. TTFB captured via curl -o /dev/null -s -w "%{time_starttransfer}" averaged over 50 sequential requests. All tests run at 02:00 local time to minimize external noise.
Baseline (no object cache) was measured with the default WordPress object cache, which stores everything in PHP memory for a single request only — no persistence between requests.
Redis vs Memcached: Feature and Performance Comparison
| Metric | No Object Cache | Redis 7.2 | Memcached 1.6 | |---|---|---| | Avg TTFB (ms) | 310 | 118 | 134 | | DB queries per page load | 94 | 11 | 13 | | Memory used (MB) | — | 28 | 31 | | Persistent across restarts | — | Yes (AOF) | No | | Data structures supported | — | Strings, lists, hashes, sets, sorted sets | Strings only | | Cluster / HA support | — | Redis Cluster, Sentinel | Basic clustering | | Managed host availability | — | Common | Less common | | PHP extension required | — | phpredis or Predis | php-memcached | | License | — | BSD (RSALv2 for v7.4+) | BSD |
The query count column deserves attention. Redis reduced per-page database queries from 94 to 11 — an 88% reduction. That is not a rounding artifact; it reflects how aggressively WordPress's object cache API deduplicates lookups when a persistent backend is present. Memcached reached 13 queries, slightly higher because W3TC's Memcached driver does not cache the alloptions group by default without extra configuration.
Where Each Backend Wins
Redis Wins On: Persistence, Data Richness, Managed Host Support
Redis supports Append-Only File (AOF) persistence. When your server restarts, the cache survives. On a WooCommerce site with thousands of cached product objects, a cold restart without persistence means every visitor for the next few minutes hits MySQL directly. With AOF enabled, the warm cache reloads from disk.
Redis also supports complex data structures. The Redis Object Cache plugin (formerly "Redis Cache" by Till Krüss) uses hash maps to store WordPress cache groups, which reduces memory overhead compared to serializing entire arrays as strings. On my test, Redis used 28 MB for the full warm cache versus Memcached's 31 MB — a small difference, but it scales.
Managed WordPress hosts have largely standardized on Redis. Kinsta, WP Engine (via their Object Cache Pro partnership), Cloudways, and Pressable all offer Redis as an add-on or include it in plans. If you are evaluating managed hosts and object caching is a priority, Redis availability is a practical filter.
Memcached Wins On: Simplicity, Multi-threaded Architecture
Memcached is genuinely simpler. It does one thing — key/value string storage — and does it with a multi-threaded architecture that can outperform Redis on pure throughput when many CPU cores are available and the workload is embarrassingly parallel. In my single-server test, this advantage did not appear because the workload was not CPU-bound on the cache side. On a dedicated cache server handling dozens of simultaneous WordPress installs (a multisite or agency scenario), Memcached's threading model can matter.
For a single WordPress site on a standard VPS or managed host, the threading advantage rarely surfaces.
Managed Host Considerations
If you are on a managed WordPress host rather than a self-managed VPS, your object cache choice may be partially made for you.
| Host | Object Cache Offered | Notes |
|---|---|---|
| Kinsta | Redis (included on all plans) | Enabled via MyKinsta dashboard, no plugin needed |
| WP Engine | Redis via Object Cache Pro (add-on) | Requires purchasing Object Cache Pro license separately |
| Cloudways | Redis (included) | Enabled per-app in the Cloudways panel |
| Pressable | Memcached (legacy), Redis on newer infra | Confirm with support for your specific server |
| Flywheel / Local | No persistent object cache on shared plans | Available on Growth Suite |
| SiteGround | Memcached on shared, Redis on GoGeek+ | Enabled via Site Tools |
On hosts that include Redis at no extra cost (Kinsta, Cloudways), the decision is straightforward: enable it. On hosts where it is an add-on, weigh the cost against your site's database query profile. A brochure site with five pages and no logged-in users will see minimal TTFB improvement from object caching because page cache handles the load. A WooCommerce store or membership site will see the 50–60% TTFB reductions demonstrated above.
Recommended Configuration for Redis on WordPress
If you are self-hosting or on a host that gives you server access, these are the settings that produced the benchmark results above.
redis.conf changes:
maxmemory 256mb
maxmemory-policy allkeys-lru
appendonly yes
appendfsync everysec
allkeys-lru evicts the least-recently-used keys when memory fills. Without this, Redis can refuse new writes once maxmemory is hit, which silently breaks object caching. appendonly yes with appendfsync everysec gives you persistence with a one-second worst-case data loss window — acceptable for a cache.
wp-config.php additions:
define( 'WP_REDIS_HOST', '127.0.0.1' );
define( 'WP_REDIS_PORT', 6379 );
define( 'WP_REDIS_MAXTTL', 3600 );
define( 'WP_REDIS_SELECTIVE_FLUSH', true );
WP_REDIS_SELECTIVE_FLUSH flushes only the current site's keys on cache purge rather than the entire Redis instance — critical if you are running multiple WordPress installs on the same Redis server.
Drop-in file: After installing the Redis Object Cache plugin, go to Settings → Redis and click "Enable Object Cache." This copies object-cache.php to wp-content/. Verify the drop-in is active — without it, Redis is running but WordPress is not using it.
Do This First
Before installing any object cache backend, run Query Monitor on your site for one week and export the query log. If your highest-traffic pages are generating fewer than 20 database queries per load and you have a page cache active, object caching will produce marginal gains — likely under 15 ms TTFB improvement. Spend that time elsewhere.
If Query Monitor shows 60+ queries per page, or if you see repeated identical queries (the "duplicate queries" panel in Query Monitor flags these), object caching will have an outsized impact.
The sequence that produced the 62% TTFB improvement in this benchmark:
- Confirm your host supports Redis or install Redis 7.x on your VPS.
- Set
maxmemoryandmaxmemory-policy allkeys-lrubefore enabling caching. - Install Redis Object Cache plugin, enable the drop-in.
- Verify connection status in the plugin dashboard (it shows hit/miss ratio).
- Run your TTFB baseline with
curl -s -w "%{time_starttransfer}" -o /dev/null [URL]averaged over 50 requests. - Compare against your pre-cache baseline.
A hit ratio below 80% after 24 hours of normal traffic suggests your maxmemory ceiling is too low or your TTL is too short. Increase maxmemory first; shorten TTL only if memory is genuinely constrained.
Conclusion
For most WordPress sites — especially WooCommerce stores, membership sites, and any installation with logged-in users — a WordPress object cache is the highest-leverage database optimization available. Redis outperformed Memcached in every measured dimension on this test stack: 118 ms vs 134 ms TTFB, 11 vs 13 database queries per page, and 28 MB vs 31 MB memory consumption.
Memcached remains a reasonable choice on hosts where it is the only option or where a multi-threaded cache server handles dozens of sites simultaneously. For a single site on a modern managed host, Redis is the practical default — it is more widely available, better supported by WordPress plugins, and adds persistence that survives server restarts.
Measure your query count before and after. The numbers will tell you whether this guide was worth implementing.