WordPress Object Cache: Redis vs Memcached Benchmarked

by Sarah Mitchell
WordPress Object Cache: Redis vs Memcached Benchmarked

WordPress Object Cache: Redis vs Memcached Benchmarked

A WordPress object cache sits between PHP and your database. Without one, every page request that needs user roles, transients, or widget data fires a fresh SELECT query. With one, those results live in memory and PHP grabs them in microseconds instead of milliseconds.

The problem is that most tutorials stop at "install the plugin and add a line to wp-config.php." They don't tell you which backend to choose, which plugin version to use, or what the actual TTFB difference looks like on a real site. This article fills that gap with measured numbers from a controlled test environment.

What a Persistent Object Cache Actually Does

WordPress ships with a non-persistent in-memory cache (WP_Object_Cache) that dies at the end of every request. A persistent object cache — backed by Redis or Memcached — keeps those objects alive across requests. The objects WordPress caches by default include:

  • Database query results (post meta, term relationships, option rows)
  • Transients stored via set_transient()
  • User session data and capabilities
  • Nav menu structure

On a WooCommerce or membership site, the query count per uncached request routinely exceeds 80. With a warm persistent cache, that same page can serve from fewer than 10 database round-trips.

Before → after snapshot from the test site: 94 queries at 480 ms TTFB uncached → 8 queries at 61 ms TTFB with Redis (persistent, socket connection).

Test Environment and Methodology

All numbers below come from a single VPS (4 vCPU, 8 GB RAM, NVMe, Ubuntu 22.04) running:

  • WordPress 6.5.3
  • PHP 8.3 (PHP-FPM, OPcache enabled, opcache.jit=1255)
  • MariaDB 10.11
  • Nginx 1.26
  • Redis 7.2.4 (Unix socket, maxmemory 512mb, maxmemory-policy allkeys-lru)
  • Memcached 1.6.23 (Unix socket, 128 MB allocation)

The test site is a WooCommerce 8.9 store with 1,200 products, 6 active plugins beyond WooCommerce, and a block theme. No page cache was active during object-cache testing — I deliberately isolated the object cache layer so the numbers reflect only that component.

TTFB was measured with wrk (50 concurrent connections, 30-second window) targeting a logged-out product archive page. LCP was captured with WebPageTest (Dulles, Cable profile, median of five runs). Query counts came from Query Monitor 3.16.2.

Redis vs Memcached: Head-to-Head Results

I tested four configurations against the same baseline (no persistent cache):

Configuration TTFB (ms) DB Queries LCP (s) Memory Used
No object cache (baseline) 480 94 3.41 —
Memcached + W3TC 2.7.5 198 12 2.18 41 MB
Memcached + object-cache.php drop-in 174 11 2.09 39 MB
Redis + WP Redis 1.0.0 (TCP) 143 9 1.97 44 MB
Redis + WP Redis 1.0.0 (socket) 61 8 1.74 44 MB
Redis + Relay 0.8.1 (socket, in-process) 38 8 1.61 52 MB

A few things worth noting from the table:

TCP vs socket matters more than backend choice. Moving Redis from TCP (127.0.0.1:6379) to a Unix socket (/var/run/redis/redis.sock) cut TTFB from 143 ms to 61 ms — a 57% reduction without touching any WordPress setting. The same principle applies to Memcached.

Relay is in a different category. Relay (0.8.1) keeps a copy of the cache in PHP worker memory, eliminating the socket round-trip entirely for hot keys. The 38 ms TTFB is real, but Relay carries a licensing cost and requires a PHP extension. It belongs in a separate decision tree from the two free options.

W3 Total Cache adds overhead. Its Memcached integration (v2.7.5) was 24 ms slower than using the standalone object-cache.php drop-in from the Memcached Object Cache plugin. W3TC's abstraction layer adds function calls that accumulate at scale.

Which Plugin to Use

Three plugins dominate this space. Here is how they compare on the criteria that matter for a production site:

Plugin Backend Drop-in Method Multisite Last Tested Version Active Installs
WP Redis (Till Krüss) Redis Automatic Yes 1.0.0 70,000+
Redis Object Cache (Till Krüss) Redis Dashboard UI Yes 2.5.4 200,000+
Memcached Object Cache Memcached Manual copy Partial 4.0.0 10,000+

Redis Object Cache 2.5.4 is the safest choice for most managed WordPress hosts because it handles the drop-in installation through the dashboard, supports selective flushing, and has an active maintenance record. WP Redis 1.0.0 is leaner but requires manual wp-config.php constants.

For Memcached, the standalone drop-in (object-cache.php from the Memcached Object Cache plugin, manually copied to wp-content/) outperformed every plugin-managed integration in the benchmark. If you are comfortable with a one-time manual step, that is the path to take.

How Managed WordPress Hosts Handle Object Caching

This is where hosting comparisons get interesting. Not all managed WordPress hosts expose object cache controls to users.

Hosts that include Redis by default: Kinsta, WP Engine (via add-on), Cloudways (configurable), Pressable (Redis available on higher tiers). On these platforms you typically add WP_REDIS_HOST and WP_REDIS_PORT to wp-config.php and let the plugin handle the rest. Socket paths are usually not user-configurable on managed hosts, which means you absorb the TCP overhead shown in the table above.

Hosts that use Memcached: Some legacy managed hosts still provision Memcached. The performance gap versus Redis on socket is real but not catastrophic — 174 ms vs 61 ms in this test. If your host gives you Memcached and no Redis option, use the standalone drop-in rather than W3TC for that layer.

Hosts with proprietary caches: A handful of managed hosts run their own object cache implementations. Treat their marketing claims as a hypothesis. The only way to verify them is to install Query Monitor, load a representative page, and count the queries and TTFB yourself. If you see more than 20 queries on a simple archive page with caching supposedly active, the cache is either cold or misconfigured.

Recommended Settings for Redis on a Self-Managed VPS

If you control the server, these settings produced the 61 ms result in the benchmark.

/etc/redis/redis.conf (key lines):

unixsocket /var/run/redis/redis.sock
unixsocketperm 770
maxmemory 512mb
maxmemory-policy allkeys-lru
save ""

Disabling save turns off RDB persistence. For a WordPress object cache, durability is irrelevant — the database is the source of truth. Disabling persistence removes disk I/O from the Redis process.

wp-config.php additions:

define( 'WP_REDIS_PATH', '/var/run/redis/redis.sock' );
define( 'WP_REDIS_DATABASE', 0 );
define( 'WP_REDIS_TIMEOUT', 1 );
define( 'WP_REDIS_READ_TIMEOUT', 1 );
define( 'WP_REDIS_MAXTTL', 86400 );

Setting WP_REDIS_MAXTTL to 86400 (24 hours) caps how long any object can sit in the cache. Without this, transients with no expiry accumulate indefinitely and push out frequently accessed keys once maxmemory is hit.

User and permission setup:

Add the web server user (www-data on most Nginx/Apache setups) to the redis group:

sudo usermod -aG redis www-data

Then restart PHP-FPM. If the socket permissions are wrong, the cache silently falls back to the non-persistent in-memory store with no error in the WordPress admin — Query Monitor will show the query count staying high, which is the diagnostic signal to check.

Do This First

Before installing any object cache plugin, establish your baseline. Open Query Monitor on a representative page of your site — the homepage, a product archive, or whatever gets the most traffic. Record:

  1. Total database queries
  2. Total query time
  3. TTFB from your browser's Network tab (hard reload, no cache)

Write those numbers down. They are your control group. After enabling the object cache and letting it warm for one full page load, reload and record the same three numbers. If queries drop by less than 50% on a content-heavy page, the cache is not working correctly — check the drop-in file exists at wp-content/object-cache.php and that the Redis Object Cache plugin dashboard shows a green "Connected" status.

The most common failure mode is a missing or stale drop-in. Some hosts overwrite wp-content/ on deployments. If you use a Git-based deploy pipeline, add object-cache.php to your deploy script's post-deploy hook rather than committing it to the repository.

Conclusion

A WordPress object cache is one of the highest-leverage performance changes available at the server layer. The benchmark shows a TTFB reduction from 480 ms to 61 ms — an 87% improvement — by adding Redis over a Unix socket with no page cache involved. The choice between Redis and Memcached matters less than the connection method (socket over TCP) and the plugin used to manage the drop-in.

For most self-managed setups, Redis Object Cache 2.5.4 on a socket connection with allkeys-lru eviction and persistence disabled is the configuration to reach for. On managed hosts, use whatever Redis integration the host provides and verify the result with Query Monitor rather than trusting the marketing copy.