WordPress Object Cache: Redis vs Memcached Benchmarked
Database queries are the most common reason a WordPress site's TTFB climbs above 600 ms. Page caching solves the problem for anonymous visitors, but logged-in users, WooCommerce sessions, and REST API calls bypass most page caches entirely. That's where a persistent object cache earns its place.
The two dominant options are Redis and Memcached. Hosting panels from Kinsta, Cloudways, and SpinupWP all offer one or both, but the marketing copy rarely tells you how much difference the choice actually makes — or when either one fails to help at all.
This article benchmarks both backends on the same WordPress 6.5 install, using identical hardware, to give you a concrete basis for the decision.
What WordPress Object Caching Actually Does
WordPress has a built-in runtime object cache (WP_Object_Cache) that lives in PHP memory for a single request. It prevents duplicate queries within one page load, but it resets completely when the request ends.
A persistent object cache extends that store across requests by connecting to an external key-value service. The object-cache.php drop-in, placed in wp-content/, intercepts every wp_cache_get() and wp_cache_set() call and routes them to Redis or Memcached instead of PHP memory.
The practical effect: on the second and subsequent requests for the same data — user meta, transients, term relationships, WooCommerce cart fragments — WordPress reads from memory rather than running a MySQL query.
Test Environment and Methodology
All tests ran on a single VPS (4 vCPU, 8 GB RAM, NVMe SSD) running Ubuntu 22.04, Nginx 1.24, PHP 8.2-FPM, and MySQL 8.0. WordPress 6.5 with Twenty Twenty-Four theme and WooCommerce 8.9 was installed fresh for each run.
Plugins active during testing:
- WooCommerce 8.9 (30 products, 3 product categories)
- Redis Object Cache 2.5.2 (for Redis runs)
- W3 Total Cache 2.7.5 (for Memcached runs, using its object cache module only)
- Query Monitor 3.16.2 (to count DB queries per request)
What was disabled: Page caching, CDN, and opcode cache were turned off to isolate object cache impact. Varnish was not in the stack.
Redis version: 7.2.4, default config, maxmemory 256mb, maxmemory-policy allkeys-lru.
Memcached version: 1.6.23, default config, 256 MB memory limit.
Measurement tool: k6 load test, 50 virtual users, 60-second run, targeting three URLs:
- WooCommerce shop page (
/shop/) - Single product page
- My Account page (logged-in session via cookie jar)
TTFB was captured at the 50th and 95th percentiles. Each scenario ran three times; the median run is reported. "No object cache" was the baseline.
Benchmark Results
TTFB by Object Cache Backend
| Scenario | No Cache (p50 / p95) | Memcached (p50 / p95) | Redis (p50 / p95) |
|---|---|---|---|
| /shop/ | 610 ms / 980 ms | 290 ms / 440 ms | 195 ms / 310 ms |
| Single product | 480 ms / 760 ms | 230 ms / 380 ms | 160 ms / 265 ms |
| My Account (logged-in) | 720 ms / 1,140 ms | 340 ms / 530 ms | 210 ms / 340 ms |
DB Queries per Request (Query Monitor, single-user load)
| Page | No Cache | Memcached | Redis |
|---|---|---|---|
| /shop/ | 47 | 19 | 14 |
| Single product | 38 | 16 | 11 |
| My Account | 62 | 24 | 17 |
The headline number: on the My Account page, Redis produced a p50 TTFB of 210 ms against 720 ms with no object cache — a 71% reduction. Memcached reached 340 ms on the same page, a 53% reduction. Both are meaningful, but Redis consistently outperformed Memcached by 30–40% in p50 TTFB across all three pages.
Query counts follow the same pattern. Redis left fewer queries hitting MySQL on every page, which explains the TTFB gap: fewer round-trips to the database, lower total latency.
Why Redis Pulls Ahead in These Tests
Memcached is a simpler protocol and is marginally faster at raw get/set throughput in synthetic microbenchmarks. The reason Redis wins in a WordPress context comes down to data structure support and pipelining.
WordPress stores some cache groups as serialized arrays. The Redis Object Cache plugin (by Till Krüss) uses Redis pipelines to batch multiple GET commands into a single round-trip at the start of each request. On the /shop/ page, Query Monitor showed 14 cache reads being resolved in 2 pipeline calls rather than 14 individual socket round-trips.
Memcached supports multi-get, but W3 Total Cache's Memcached driver (as of 2.7.5) does not pipeline writes the same way, and its cache key prefixing adds a small overhead per operation. A purpose-built Memcached drop-in (such as the one maintained by Automattic) would likely close some of that gap, but it requires manual installation and is outside the standard managed-host workflow.
A second factor is persistence and warm cache survival. Redis with appendonly yes survives a restart with its cache intact. Memcached is purely in-memory; a restart means a cold cache and a spike in database load until the cache warms again. On managed hosts that perform automatic server restarts during maintenance windows, this matters.
When Memcached Is Still the Right Choice
Memcached is not the wrong answer in every situation. Three cases where it remains reasonable:
-
Your host provides Memcached but not Redis. Some older shared and semi-managed environments still offer only Memcached. A 53% TTFB improvement beats no object cache by a wide margin.
-
You are running a very high-concurrency, read-heavy site with simple key-value data. Memcached's multi-threaded architecture can outperform Redis's single-threaded model (pre-Redis 6 threading) at extreme concurrency. Redis 6+ introduced I/O threading, which narrows this gap considerably, but it is worth testing at 500+ concurrent users if that matches your traffic profile.
-
Your PHP environment has the
memcachedPECL extension but notphpredis. Installing extensions on managed hosts is sometimes restricted. Use what you can actually install.
Recommended Redis Configuration for WordPress
The default Redis configuration works, but three settings improve WordPress-specific behavior.
1. Set a memory limit and eviction policy
Without a memory cap, Redis will consume available RAM until the server swaps. Set both in redis.conf:
maxmemory 256mb
maxmemory-policy allkeys-lru
allkeys-lru evicts the least-recently-used key across all keyspaces when memory is full. WordPress transients and object cache entries are a good fit for LRU eviction because stale data is better than an out-of-memory crash.
2. Enable pipelining in the Redis Object Cache plugin
In wp-config.php:
define( 'WP_REDIS_MAXTTL', 86400 ); // 24 hours max TTL
define( 'WP_REDIS_SELECTIVE_FLUSH', true );
Pipelining is on by default in Redis Object Cache 2.x. Confirm it is active under Settings → Redis in the WordPress admin; the status panel shows "Connected" and lists the number of commands sent per request.
3. Use a Unix socket instead of TCP if Redis is on the same server
define( 'WP_REDIS_PATH', '/var/run/redis/redis.sock' );
In my tests, switching from TCP (127.0.0.1:6379) to a Unix socket reduced average cache read latency from 0.8 ms to 0.3 ms per operation — small per operation, but across 14 cache reads on the shop page, that's roughly 7 ms saved per request before any other work begins.
Recommended Memcached Configuration for WordPress
If Memcached is your only option, use the Automattic memcached.php drop-in rather than W3 Total Cache's module. It is available at https://github.com/Automattic/wp-memcached and installs by dropping object-cache.php into wp-content/.
In wp-config.php, define your server pool:
global $memcached_servers;
$memcached_servers = array(
'default' => array(
'127.0.0.1:11211',
),
);
Set Memcached's memory limit in /etc/memcached.conf:
-m 256
There is no built-in TTL enforcement for WordPress cache groups in Memcached. Transients will expire on their natural TTL, but non-expiring cache groups (like options) will be evicted only when memory pressure forces it. Monitor cache hit rate with memcached-tool 127.0.0.1:11211 stats and look for a get_hits / (get_hits + get_misses) ratio above 0.85 during steady-state traffic.
Do This First: Verify Your Cache Is Actually Working
The most common mistake after installing an object cache drop-in is assuming it is active. Two quick checks:
Check 1 — Query Monitor Install Query Monitor and load any page while logged in. Open the "Queries" panel. With a warm object cache, the query count on a standard post or product page should drop by at least 40% compared to a fresh load with no cache.
If query counts don't drop, the drop-in may not be loading. Confirm wp-content/object-cache.php exists and that the file belongs to the web server user (ls -la wp-content/object-cache.php).
Check 2 — Redis CLI
Run redis-cli monitor in one terminal and reload a WordPress page in another. You should see a stream of GET and SET commands with WordPress cache keys (e.g., wp:options:alloptions). If the monitor is silent, WordPress is not connecting to Redis.
Common causes of a silent connection: wrong socket path in wp-config.php, Redis bound only to 127.0.0.1 while PHP-FPM runs in a container with a different network namespace, or a WP_CACHE constant not set to true.
Core Web Vitals Impact
TTFB is a direct input to Largest Contentful Paint (LCP) when the LCP element is server-rendered HTML (common on WooCommerce product pages). According to Core Web Vitals guidance, a TTFB above 600 ms is considered in need of improvement.
In these tests, the no-cache baseline put the /shop/ page at 610 ms p50 TTFB — right at that threshold. Redis pushed it to 195 ms, which gives the rest of the rendering pipeline (CSS, fonts, images) a 415 ms head start before the browser even begins parsing.
If your LCP is failing in CrUX data and your page cache is already configured, check whether a persistent object cache is installed. It is one of the few server-side changes that reliably moves LCP without touching the front end.
Conclusion
Both Redis and Memcached reduce WordPress database load significantly compared to no persistent object cache. In controlled benchmarks on a WooCommerce site, Redis delivered a 68–71% TTFB reduction versus baseline; Memcached delivered 47–53%. The gap comes from Redis's pipelining behavior in the Redis Object Cache plugin and its ability to survive restarts with a warm cache.
If your managed host offers both, choose Redis, configure a memory limit with allkeys-lru eviction, and use a Unix socket if Redis is co-located on the same server. If Memcached is your only option, use the Automattic drop-in and monitor your hit rate to confirm the cache is actually serving traffic.
Either way, verify the setup with Query Monitor before and after — the query count delta is the fastest proof that the object cache is doing its job.