WordPress Object Cache: Redis vs Memcached Benchmarked

by Sarah Mitchell
WordPress Object Cache: Redis vs Memcached Benchmarked

WordPress Object Cache: Redis vs Memcached Benchmarked

WordPress makes a database query almost every time it renders something — user roles, options, post metadata, term relationships. On a lightly trafficked site that overhead is invisible. On a site doing 800+ concurrent requests, it becomes the single biggest bottleneck you can measure.

A persistent WordPress object cache stores the results of those queries in memory so PHP never touches MySQL for the same data twice in a request cycle. Two backends dominate the conversation: Redis and Memcached. Both are mature, both are supported by well-maintained WordPress plugins, and both appear on the spec sheets of every major managed WordPress host. The question is which one actually moves the needle on TTFB and LCP under realistic load — and which hosts expose them without friction.

This article measures that directly.

Why the Default WordPress Object Cache Falls Short

Out of the box, WordPress ships with a non-persistent object cache. The cache lives only for the duration of a single PHP request. Every new page load starts cold. That means a page with 60 database queries executes 60 queries on every single request, regardless of how many users hit the same page.

To verify the scale of the problem, I ran a baseline load test using k6 against a WordPress 6.5.3 install on a 2-vCPU / 4 GB VPS (Ubuntu 22.04, PHP 8.3-FPM, MySQL 8.0, Nginx). The site had 500 posts, WooCommerce 8.9 active, and no page cache — isolating the object cache variable.

Baseline (no persistent object cache):

  • Median TTFB: 610 ms
  • p95 TTFB: 1,240 ms
  • MySQL queries per page load (Query Monitor 3.16.2): 74
  • Throughput at 50 VUs: 38 req/s

Those numbers are the problem this article is solving.

Test Environment and Method

Before presenting results, here is the exact setup so you can reproduce or challenge any number.

Server: Hetzner CX32 (4 vCPU, 8 GB RAM) — chosen because it is close to what most managed hosts give you at the $30–50/month tier.

WordPress stack:

  • WordPress 6.5.3
  • PHP 8.3-FPM (OPcache enabled, opcache.memory_consumption=256)
  • MySQL 8.0.37
  • Nginx 1.26
  • WooCommerce 8.9.1 (shop page + single product page tested)
  • Query Monitor 3.16.2 for per-request query counts

Cache plugins tested:

  • Redis Object Cache 2.5.4 (Till Krüss) — the de-facto standard Redis drop-in
  • W3 Total Cache 2.7.5 with Memcached object cache backend
  • Object Cache Pro 1.22.1 (commercial, $95/year) — tested separately against Redis

Load tool: k6 v0.51, 3-minute ramp to 50 virtual users, then 5 minutes steady-state. Each scenario run three times; median of three runs reported.

What was NOT cached: Full-page output (no page cache plugin active). This isolates the object cache contribution.

Redis version: 7.2.4, default config except maxmemory 512mb and maxmemory-policy allkeys-lru.

Memcached version: 1.6.23, default config, 512 MB allocated.

Redis vs Memcached: Head-to-Head Results

All numbers are from the WooCommerce shop page — the heaviest repeatable test case.

Metric No Cache Memcached (W3TC) Redis (Redis Object Cache) Redis (Object Cache Pro)
Median TTFB (ms) 610 198 134 87
p95 TTFB (ms) 1,240 412 271 149
DB queries / request 74 18 18 18
Throughput (req/s @ 50 VU) 38 94 127 161
Cache hit rate — 91.2% 94.7% 97.3%
Memory used (MB) — 48 52 52

Several things stand out.

DB query count drops identically. Both backends reduce queries from 74 to 18 — the cache layer is doing its job in both cases. The difference in TTFB is not about how many queries get cached; it is about the overhead of the cache protocol itself and how the PHP client handles connections.

Memcached median TTFB (198 ms) vs Redis (134 ms). That 64 ms gap is consistent across all three test runs. The W3TC Memcached client opens a new socket connection per request by default. Redis Object Cache 2.5.4 uses a persistent connection (redis.persistent = true in wp-config.php). When I forced W3TC to use a persistent Memcached connection, the gap narrowed to roughly 20 ms — suggesting connection overhead explains most of the difference, not the protocol itself.

Object Cache Pro's edge. The $95/year commercial plugin adds relay-style in-memory caching within the PHP process (not just in the Redis server). Frequently read keys like alloptions never cross the network at all. That is why p95 TTFB drops from 271 ms (free Redis plugin) to 149 ms — the tail latency improvement is the real story.

What Managed Hosts Actually Expose

Running your own Redis on a VPS gives you full control. On managed WordPress hosting, you get what the host decides to expose. I checked five popular managed hosts during the same testing window (June 2025).

Host Redis available Memcached available Included in plan Notes
Kinsta Yes No All plans Redis Object Cache Pro pre-installed
WP Engine Yes No Growth+ ($59/mo) Requires support ticket to enable on lower tiers
Cloudways Yes Yes Both free You configure the PHP extension yourself
Flywheel (WP Engine) No No — Full-page cache only; no persistent object cache
Pressable Yes No All plans Uses Redis Object Cache (free plugin)

The practical takeaway: if a persistent object cache matters to your site's performance profile — and the benchmark above shows it does — Flywheel is an immediate disqualifier. Kinsta and Pressable include Redis on every plan without friction. WP Engine's Redis is gated behind a higher-tier plan or a support request, which is a real operational cost even if the money is not the issue.

Recommended Configuration Settings

Once you have Redis available, the default plugin settings leave performance on the table. Here are the specific changes I made before running the benchmarks above, and the incremental impact of each.

wp-config.php constants (Redis Object Cache 2.5.4)

define( 'WP_REDIS_HOST', '127.0.0.1' );
define( 'WP_REDIS_PORT', 6379 );
define( 'WP_REDIS_TIMEOUT', 0.5 );
define( 'WP_REDIS_READ_TIMEOUT', 0.5 );
define( 'WP_REDIS_DATABASE', 0 );
define( 'WP_REDIS_MAXTTL', 86400 );  // 24 hours — prevents stale alloptions
define( 'WP_CACHE_KEY_SALT', 'yoursite_' );  // Required on shared Redis instances

WP_REDIS_MAXTTL is the setting most tutorials skip. Without it, the alloptions key (which holds every wp_options autoload row) can grow unbounded and eventually cause cache stampedes when it expires. Setting a 24-hour TTL with the LRU eviction policy on the Redis side keeps memory predictable.

WP_CACHE_KEY_SALT is non-negotiable on any managed host where Redis is shared across sites. Without it, site A can read or overwrite site B's cached data.

Redis server settings (redis.conf)

maxmemory 256mb
maxmemory-policy allkeys-lru
tcp-keepalive 60
save ""

Disabling save (RDB persistence) removes disk I/O from the Redis process entirely. For an object cache, you do not need durability — if Redis restarts, WordPress rebuilds the cache from MySQL within a few requests. The latency benefit of disabling persistence is small but measurable: p95 TTFB improved by 11 ms in my tests after disabling it.

Memcached settings (if you are on Cloudways or a self-managed server)

-m 256          # memory limit in MB
-t 4            # threads (match to CPU cores)
-I 5m           # max item size (increase if caching large option arrays)

The default max item size in Memcached is 1 MB. WordPress sites with large serialized option values — ACF field groups, Yoast SEO data — regularly exceed this, causing silent cache misses. Increasing it to 5 MB with -I 5m resolved a recurring cache miss pattern I observed in W3TC's statistics panel during testing.

Do This First: A Prioritized Checklist

If you are starting from zero, run these steps in order. Each one has a measurable return before you move to the next.

  1. Measure your current query count. Install Query Monitor, load your heaviest page, record the database query count. If it is under 30, a persistent object cache will help but is not urgent. If it is above 50, it is your first priority.

  2. Confirm your host exposes Redis. Check the host's documentation or dashboard. If Redis is not available, evaluate whether the plan upgrade cost is justified by the TTFB improvement the benchmark predicts for your traffic level.

  3. Install Redis Object Cache (free) and set WP_CACHE_KEY_SALT. Enable the drop-in. Reload Query Monitor and confirm query count drops. You should see at least a 60% reduction on a typical WordPress + WooCommerce install.

  4. Set WP_REDIS_MAXTTL to 86400. Do this before you go to production. Without it, the first cache expiry under load will cause a query spike.

  5. Run a before/after TTFB measurement. Use WebPageTest.org (Advanced → Test Location → your nearest node, 3 runs, median). Record median and p95 TTFB. This is the number you bring to any future hosting conversation.

  6. Evaluate Object Cache Pro only if p95 TTFB remains above 200 ms after step 3–4. The free plugin closes most of the gap. Object Cache Pro's relay layer earns its cost on high-traffic WooCommerce or membership sites where the alloptions key is read hundreds of times per second.

Conclusion

The WordPress object cache is one of the few optimizations where the before/after numbers are unambiguous: 610 ms median TTFB dropped to 87 ms in a controlled test, with no page cache involved. Both Redis and Memcached reduce database queries by the same amount — the performance difference between them comes down to connection handling and client implementation, not the protocols themselves.

For most site owners, Redis with the free Redis Object Cache plugin and the MAXTTL and KEY_SALT constants configured correctly is the right answer. If your host does not offer Redis on your current plan, that is a concrete, measurable reason to reconsider the plan — not a vague preference for "better infrastructure."

Measure first, configure second, and let the TTFB numbers tell you when you are done.