WordPress Object Cache: Redis vs Memcached Benchmarked
A WordPress object cache is one of the highest-leverage performance changes you can make to a database-heavy site, yet most hosting comparisons skip it entirely in favor of page-cache metrics. That gap matters: page cache misses — logged-in users, WooCommerce sessions, personalized content — fall through to the database on every request. The WordPress object cache intercepts those queries before they hit MySQL.
This article measures what actually changes when you enable a persistent object cache on a self-managed VPS and on three managed WordPress hosts, using Redis and Memcached as the two backends.
What the WordPress Object Cache Actually Does
WordPress ships with a non-persistent in-memory cache (WP_Object_Cache). It stores query results for the duration of a single PHP request, then discards them. Every new request starts cold.
A persistent object cache — backed by Redis or Memcached — keeps those results alive across requests. The next visitor asking for the same data gets it from RAM, not from a MySQL round-trip.
The practical impact shows up in two places:
- TTFB (Time to First Byte): fewer database queries means PHP finishes faster.
- Database CPU: lower query volume means the database server idles more, which matters on shared or limited-resource plans.
Neither metric appears in most hosting marketing, which is exactly why it's worth measuring directly.
Test Setup and Methodology
All tests ran against a WooCommerce 8.7 store with 1,200 products, 14 active plugins, and a logged-in user session (cart active, no page-cache hit possible). The theme was Storefront 4.4.1 with no child-theme modifications.
Infrastructure tested:
- Self-managed VPS: 2 vCPU / 4 GB RAM, Ubuntu 22.04, PHP 8.2-FPM, Nginx, MySQL 8.0
- Managed host A: entry-level managed WordPress plan (512 MB RAM container)
- Managed host B: mid-tier managed WordPress plan (1 GB RAM container, Redis available as add-on)
- Managed host C: agency-tier managed WordPress plan (Redis enabled by default)
Host names are withheld because plan availability changes; the methodology is what transfers.
Measurement tool: WebPageTest (Dulles, VA location, Cable connection profile, 9 runs, median result reported). TTFB recorded at the server-response stage, not the browser-paint stage.
Load test: k6 at 50 virtual users, 2-minute ramp, logged-in session cookie replayed. Database query count captured via Query Monitor 3.16.0 with the QM_DB_QUERIES constant enabled.
Baseline: No persistent object cache, WordPress default in-memory cache only.
Results: TTFB and Query Count by Configuration
The table below shows median TTFB and database query count per page load for the WooCommerce cart page — the hardest page to cache on this store.
| Configuration | Median TTFB | DB Queries / Load | Δ TTFB vs Baseline |
|---|---|---|---|
| No object cache (baseline) | 620 ms | 187 | — |
| Memcached (VPS, default config) | 241 ms | 34 | −61% |
| Redis (VPS, default config) | 198 ms | 34 | −68% |
Redis (VPS, maxmemory-policy allkeys-lru) |
118 ms | 34 | −81% |
| Managed host A — no persistent cache | 580 ms | 191 | −6% |
| Managed host B — Redis add-on enabled | 204 ms | 36 | −67% |
| Managed host C — Redis default | 131 ms | 33 | −79% |
Query count dropped from 187 to roughly 34 in every persistent-cache configuration. The difference between Redis and Memcached at the same query count is latency architecture: Redis keeps its data structures in a single-threaded event loop with optional persistence, while Memcached uses a multi-threaded slab allocator. For WordPress's access pattern — many small key-value reads — Redis's lower per-operation overhead won on this hardware.
The allkeys-lru eviction policy change on the VPS is the single biggest jump in the table (198 ms → 118 ms). More on that in the configuration section below.
Redis vs Memcached: Where Each One Wins
The benchmark above favors Redis, but Memcached is not obsolete. The right choice depends on your hosting constraints and site behavior.
Redis advantages for WordPress:
- Supports data persistence (
RDBsnapshots orAOFlogging), so the cache survives a PHP-FPM restart without a cold-start penalty. - Handles WordPress transients natively — the Redis Object Cache plugin (version 2.5.x) maps
set_transient()calls to RedisSETEX, keeping TTLs accurate. - Supports clustering if you ever need horizontal scale.
- Most managed WordPress hosts that offer a persistent cache ship Redis, not Memcached.
Memcached advantages:
- Lower memory overhead per process on very constrained containers (sub-256 MB).
- Multi-threaded, so it scales better on hosts that give you many cores but little RAM.
- Simpler operational model if you're managing your own server and want fewer moving parts.
When Memcached still makes sense: shared hosting environments where Redis is not available, or legacy setups already running Memcached that don't justify a migration risk.
| Factor | Redis | Memcached |
|---|---|---|
| Persistence across restarts | Yes (optional) | No |
| Transient TTL accuracy | Native | Requires workaround |
| Memory efficiency (small objects) | Moderate | High |
| Multi-threading | No (single-threaded) | Yes |
| Managed WP host availability | Common | Rare |
| Plugin ecosystem (WordPress) | Redis Object Cache 2.5.x | Memcached Object Cache |
Recommended Configuration Settings
Default Redis and Memcached installs leave performance on the table. These are the specific settings that produced the numbers in the table above.
Redis on a Self-Managed VPS
Edit /etc/redis/redis.conf:
maxmemory 256mb
maxmemory-policy allkeys-lru
save ""
appendonly no
tcp-backlog 511
tcp-keepalive 300
Why allkeys-lru: WordPress object cache keys do not all carry explicit TTLs. Without allkeys-lru, Redis uses noeviction by default and returns errors when memory fills. allkeys-lru evicts the least-recently-used key regardless of TTL, which matches WordPress's access pattern and eliminated the 80 ms of latency spikes seen at the 50-VU load in testing.
Why save "": Disabling RDB snapshots removes periodic disk I/O that caused 40–60 ms latency spikes under load on the test VPS. If your site cannot tolerate a cold cache after a Redis restart, re-enable snapshots and accept the trade-off.
WordPress Plugin Configuration (Redis Object Cache 2.5.x)
Add to wp-config.php:
define( 'WP_REDIS_HOST', '127.0.0.1' );
define( 'WP_REDIS_PORT', 6379 );
define( 'WP_REDIS_DATABASE', 0 );
define( 'WP_REDIS_TIMEOUT', 1 );
define( 'WP_REDIS_READ_TIMEOUT', 1 );
define( 'WP_REDIS_MAXTTL', 86400 );
WP_REDIS_MAXTTL caps object lifetime at 24 hours. Without it, stale product data persisted in cache after stock updates during the WooCommerce test, causing a visible inventory discrepancy. Set it lower (3600–14400) for stores with frequent inventory changes.
Memcached on a Self-Managed VPS
Edit /etc/memcached.conf:
-m 256
-I 2m
-t 4
-o modern
-I 2m raises the maximum object size to 2 MB, which matters for WordPress sites storing large serialized arrays (nav menus, widget data). The default 1 MB limit causes silent cache misses for those objects.
Managed WordPress Hosting: What to Look For
The managed host results in the benchmark table show a 449 ms spread between the worst (host A, no persistent cache) and the best (host C, Redis default). That gap is larger than the difference between Redis and Memcached on the same VPS.
When evaluating managed WordPress hosts on object cache support, ask or test for:
- Is Redis or Memcached included, or is it a paid add-on? Host B's Redis add-on cost an additional $10/month on the plan tested. Host C included it at the same price tier.
- What is the allocated Redis memory? Host B provided 64 MB. Host C provided 256 MB. At 64 MB with
allkeys-lru, eviction was aggressive enough to reduce hit rate to 71% under the 50-VU load (measured viaredis-cli INFO stats,keyspace_hits/ (keyspace_hits+keyspace_misses)). - Can you set
maxmemory-policy? Most managed hosts lock Redis configuration. Host C allowed policy changes via a dashboard toggle. Host B did not. - Does the host's object cache conflict with their page cache? One host (not in this test set) documented that enabling a third-party Redis plugin bypassed their proprietary full-page cache layer. Always verify in staging.
Do This First
Before touching Redis or Memcached configuration, run Query Monitor on your highest-traffic non-cacheable page and record the baseline query count. If it's under 30 queries, your site may already have a warm object cache or a well-optimized query structure — the gains will be smaller.
If your query count is above 80 on a non-cached page load, a persistent object cache is the highest-ROI change available to you, ahead of image optimization, CDN tuning, or PHP version upgrades.
The sequence that produced the best results in this test:
- Install and activate Redis Object Cache plugin (2.5.x).
- Set
maxmemory-policy allkeys-lruin Redis config. - Add
WP_REDIS_MAXTTLtowp-config.phpappropriate to your content update frequency. - Verify cache hit rate with
redis-cli INFO statsafter 15 minutes of live traffic. - Re-run WebPageTest (or your equivalent) and compare TTFB on the same page, same connection profile.
The 620 ms → 118 ms improvement in this test came from steps 1 through 3 in that order. Step 2 alone accounted for 80 ms of the improvement; the rest came from eliminating database round-trips entirely.
Conclusion
The WordPress object cache is a measurable, configurable layer that most hosting reviews ignore. On a WooCommerce store with logged-in sessions, enabling Redis with correct eviction policy dropped TTFB from 620 ms to 118 ms — an 81% reduction — without changing a single line of theme or plugin code.
Memcached remains a viable alternative on constrained multi-core environments, but Redis's persistence, TTL accuracy, and wider availability on managed WordPress hosts make it the practical default for most sites. This guide on building storefronts demonstrates how infrastructure choices compound across the stack; the configuration details — eviction policy, max TTL, object size limits — matter as much as which backend you choose.