How to Set Up Redis Object Cache in WordPress (Complete 2026 Guide)

TL;DR: Redis object cache stores the results of expensive database queries in memory, so WordPress retrieves them instantly on repeat requests instead of hitting MySQL every time. Setting it up takes about 20 minutes: install Redis on your server, connect it to WordPress via wp-config.php constants, and activate the Redis Object Cache plugin. Sites with heavy query loads routinely cut server response times by 50 to 80 percent after the switch.

Last Updated: October 2026. This guide targets WordPress 6.7, PHP 8.3, and Redis 7.x.

If your WordPress site feels sluggish even after enabling a page cache plugin, the bottleneck is often the database. Every page load triggers dozens of MySQL queries: fetching options, resolving user data, pulling widget configurations, and more. Redis object cache intercepts those queries, stores the results in RAM, and hands them back to WordPress in under a millisecond on repeat calls. This guide walks you through the complete wordpress redis object cache setup from a bare server to verified cache hits.

What Is Redis Object Cache and Why It Matters in 2026

Try GigaPress AI Free →

WordPress ships with a built-in object cache API. By default that cache lives only in memory for the duration of a single PHP request and evaporates the moment the request ends. A persistent object cache backend like Redis keeps those cached objects alive across requests, meaning the second visitor to your homepage never triggers the same database work the first visitor did.

Redis (Remote Dictionary Server) is an open-source, in-memory data store. It holds key-value pairs in RAM with optional disk persistence. When used as a WordPress object cache backend, it intercepts every call to wp_cache_get() and wp_cache_set() and routes them to Redis instead of discarding them. The result is a persistent, site-wide query cache that survives PHP process restarts.

Memcached is the other common alternative, but Redis has become the practical default in 2026 because it supports more data structures, offers built-in replication, and is available as a managed add-on on virtually every serious hosting platform, including Kinsta, WP Engine, Cloudways, and GridPane.

Before You Start: Server Prerequisites

Redis object cache only works on hosting environments where you have access to a Redis instance. Shared hosting plans almost never offer this. You need one of the following:

  • A VPS or dedicated server where you can install and manage Redis yourself (DigitalOcean, Linode, Vultr, Hetzner)
  • A managed WordPress host that includes Redis as a plan feature or paid add-on (Kinsta, WP Engine, Cloudways, GridPane)
  • A cloud host with a managed Redis service (AWS ElastiCache, Google Cloud Memorystore, Azure Cache for Redis)

You also need:

  • PHP 8.1 or higher (8.3 recommended)
  • The phpredis PHP extension OR the pure-PHP Predis library (the plugin supports both; phpredis is faster)
  • SSH access to your server if you are doing a manual install
  • WordPress 6.4 or higher

Check whether Redis is already running on your server:

redis-cli ping

If it returns PONG, Redis is installed and running. Skip ahead to the plugin installation section. If you get a “command not found” error, work through the installation steps below.

Step 1: Install Redis on a VPS (Ubuntu 24.04 / Debian 12)

If your managed host provides Redis, skip this section and use the connection details from your hosting dashboard. For VPS installs, follow these commands as root or a sudo user.

Install Redis:

sudo apt update
sudo apt install redis-server -y

Enable and start the service:

sudo systemctl enable redis-server
sudo systemctl start redis-server
sudo systemctl status redis-server

Harden the default configuration by editing /etc/redis/redis.conf. At minimum, set a password and bind Redis to localhost only so it is not exposed to the public internet:

# /etc/redis/redis.conf
bind 127.0.0.1 ::1
requirepass YourStrongPasswordHere
maxmemory 256mb
maxmemory-policy allkeys-lru

The maxmemory-policy allkeys-lru setting tells Redis to evict the least-recently-used keys when it reaches the memory limit, which is the correct behavior for a cache workload. Restart Redis after saving:

sudo systemctl restart redis-server
redis-cli -a YourStrongPasswordHere ping

Install the phpredis extension (required for the WordPress plugin’s best performance mode):

sudo apt install php8.3-redis -y
sudo systemctl restart php8.3-fpm

Confirm the extension loaded:

php -m | grep redis

You should see redis in the output.

Step 2: Configure wp-config.php Constants

Open your site’s wp-config.php file and add the Redis connection constants above the line that reads /* That's all, stop editing! Happy publishing. */.

For a local Redis install (most VPS setups):

define( 'WP_REDIS_HOST', '127.0.0.1' );
define( 'WP_REDIS_PORT', 6379 );
define( 'WP_REDIS_PASSWORD', 'YourStrongPasswordHere' );
define( 'WP_REDIS_TIMEOUT', 1 );
define( 'WP_REDIS_READ_TIMEOUT', 1 );
define( 'WP_REDIS_DATABASE', 0 );

For a Redis instance provided by a managed host via a socket (common on Kinsta and GridPane):

define( 'WP_REDIS_SCHEME', 'unix' );
define( 'WP_REDIS_PATH', '/var/run/redis/redis.sock' );
define( 'WP_REDIS_DATABASE', 0 );

If you run multiple WordPress sites on the same Redis instance, assign each a unique database index or prefix to prevent key collisions:

define( 'WP_REDIS_PREFIX', 'mysite_' );
define( 'WP_REDIS_DATABASE', 1 ); // Use a different DB index per site

The timeout constants deserve attention. Setting WP_REDIS_TIMEOUT and WP_REDIS_READ_TIMEOUT to 1 second means that if Redis becomes unavailable, WordPress falls back gracefully to the default in-memory cache after one second rather than hanging the request. This is important for production reliability.

Step 3: Install and Activate the Redis Object Cache Plugin

The Redis Object Cache plugin by Till Kruss is the standard solution for connecting WordPress to Redis. It has over 100,000 active installs on WordPress.org and is actively maintained as of 2026. Install it from your WordPress dashboard under Plugins, then search for “Redis Object Cache.”

Alternatively, install via WP-CLI:

wp plugin install redis-cache --activate

After activation, navigate to Settings, Redis in your WordPress admin. You will see a status panel. If your wp-config.php constants are correct and Redis is running, the status will show “Connected.” Click the Enable Object Cache button.

What the button does internally: it copies the plugin’s object-cache.php drop-in file into your wp-content/ directory. WordPress automatically loads any file named object-cache.php found there, hooking Redis into the object cache API before any plugins run. You can verify the file exists:

ls -la /var/www/html/wp-content/object-cache.php

Step 4: Verify Cache Hits in 2026

After enabling the cache, reload your site and return to Settings, Redis. The diagnostics panel shows real-time statistics: hits, misses, the hit ratio percentage, memory used, and the number of cached keys. A healthy production site typically shows a hit ratio above 80 percent after a few minutes of traffic.

Verify via WP-CLI:

wp redis status
wp redis info

Verify directly in Redis CLI:

redis-cli -a YourStrongPasswordHere
> INFO stats
> DBSIZE

The keyspace_hits and keyspace_misses counters in the INFO stats output let you calculate the raw hit ratio. If you see a large number of keys growing in DBSIZE, the cache is populating correctly.

Check via Query Monitor plugin: If you have Query Monitor installed, its “Object Cache” panel shows per-request hit and miss counts, which is useful for debugging why certain pages generate many misses.

Performance Benchmarks: Before and After Redis

Real-world performance gains depend on your site’s query load, theme complexity, and active plugins. The table below shows typical ranges measured on a 2-vCPU VPS running Nginx, PHP 8.3-FPM, and MySQL 8.0, with a WooCommerce store as the test subject.

Metric Without Redis With Redis Typical Improvement
Time to First Byte (TTFB) 350 to 600 ms 80 to 150 ms 60 to 75% reduction
MySQL queries per page load 40 to 120 5 to 20 70 to 85% reduction
Requests per second (ab benchmark) 12 to 25 55 to 110 4x to 5x increase
WP admin dashboard load 800 ms to 1.5 s 200 to 400 ms 50 to 70% reduction
Redis memory used (typical blog) N/A 20 to 80 MB Very efficient RAM use

These numbers are most dramatic on sites with heavy plugin stacks, WooCommerce product catalogs, or WordPress multisite installations. A simple blog with a lightweight theme will still see improvement, but the baseline query count is lower so the absolute gains are smaller.

For further context on multisite setups and how Redis fits into larger WordPress architectures, see the WordPress Multisite Setup Guide 2026 and the WordPress Server-Side Performance Optimization guide covering PHP OPcache and MySQL tuning alongside Redis.

Advanced Configuration Options

Selective cache exclusions: Some data should not be cached in Redis. User session data, transients tied to real-time feeds, and WooCommerce cart data are common candidates for exclusion. Add exclusion filters in your theme’s functions.php or a site-specific plugin:

add_filter( 'redis_cache_ignored_groups', function( $groups ) {
    $groups[] = 'wc_session_id';
    $groups[] = 'counts'; // Forces fresh counts for post types
    return $groups;
} );

Setting a global TTL: By default, cached objects live in Redis until they are explicitly invalidated or until Redis evicts them under memory pressure. You can set a maximum time-to-live in seconds to force periodic refresh:

define( 'WP_REDIS_MAXTTL', 86400 ); // 24 hours in seconds

Using Redis Sentinel or Redis Cluster for high-availability setups: If you run a high-traffic site with a Redis Sentinel or Cluster setup, the plugin supports both. Configure Sentinel in wp-config.php:

define( 'WP_REDIS_SENTINEL', 'mymaster' );
define( 'WP_REDIS_SERVERS', [
    'tcp://10.0.0.1:26379',
    'tcp://10.0.0.2:26379',
    'tcp://10.0.0.3:26379',
] );

Flushing the cache: After major content updates or plugin changes, flush Redis via WP-CLI rather than clicking through the admin panel, as it is faster and scriptable:

wp redis flush

Redis vs Page Cache: Understanding the Difference

Redis vs Page Cache: Understanding the Difference

A common point of confusion: Redis object cache and full-page cache are not the same thing, and they are not mutually exclusive. They work at different layers and are most effective when used together.

Cache Type What It Caches Who Benefits Most Example Tools
Object Cache (Redis) Database query results, options, transients Logged-in users, WooCommerce, dynamic pages Redis Object Cache plugin
Page Cache Full rendered HTML pages Anonymous visitors, static blog posts WP Rocket, W3 Total Cache, LiteSpeed Cache
OPcache Compiled PHP bytecode Every WordPress site Built into PHP 8.x, no plugin needed
CDN Cache Static assets (images, JS, CSS) Global audiences, media-heavy sites Cloudflare, BunnyCDN, Amazon CloudFront

The best-performing WordPress sites layer all four: OPcache handles PHP compilation, Redis handles database query results, a page cache handles full HTML for anonymous visitors, and a CDN handles static assets. Each layer removes a different bottleneck. For more on choosing the right WordPress hosting environment that supports these features, see our hosting comparison guides.

Troubleshooting Common Redis Setup Problems

Status shows “Not connected” after enabling: Check that the phpredis extension is loaded (php -m | grep redis), that the password in wp-config.php matches /etc/redis/redis.conf, and that Redis is actually running (systemctl status redis-server). Also confirm there is no firewall rule blocking port 6379.

Hit ratio stays below 20 percent: This usually means cache keys are being invalidated too aggressively. Check whether a plugin (often a security scanner or a broken cron job) is flushing the object cache on every request. Query Monitor will expose this behavior in its object cache panel.

Redis runs out of memory and starts evicting keys aggressively: Increase maxmemory in redis.conf, or review which cache groups are storing oversized values. Run redis-cli --bigkeys to identify the largest keys in your cache.

WooCommerce cart or session data acting erratically: Add the wc_session_id group to the ignored groups filter shown in the advanced configuration section. WooCommerce session data is user-specific and should not be served from a shared object cache.

Object cache drop-in warning in the WordPress admin: This appears when the object-cache.php file in wp-content does not match the plugin’s expected version. Disable and re-enable the cache from Settings, Redis to refresh the drop-in.

For SSL and security hardening that complements your performance stack, the WordPress SSL Certificate setup guide covers HTTPS configuration alongside server-level best practices.

Want a Pro WordPress Site in Minutes?

GigaPress AI builds you a full WordPress site in about 15 minutes — AI handles layout, styling, content, and images. Free to design, only pay when you’re ready to go live. If you need a high-performance WordPress foundation with object caching, OPcache, and server-level optimization already configured, GigaPress AI Builder sets up a production-ready site so you can skip straight to the tuning stage.

Frequently Asked Questions

Does Redis object cache work on shared hosting?

Rarely. Most shared hosting plans do not expose a Redis instance to individual accounts. You need a VPS, dedicated server, or a managed WordPress host that includes Redis as a feature. If your host does not support Redis, Memcached is sometimes available as an alternative, or you can move to a host with Redis support.

Will Redis object cache conflict with WP Rocket or WP Super Cache?

No. Redis object cache and full-page cache plugins operate at different levels. Redis caches database objects; WP Rocket and similar plugins cache rendered HTML. They complement each other and are safe to run simultaneously. In fact, using both together produces better performance than either one alone.

How much RAM should I allocate to Redis for a WordPress site?

A typical WordPress blog or small business site uses 20 to 80 MB of Redis memory. A WooCommerce store with a large product catalog might use 100 to 300 MB. Start with a 256 MB maxmemory limit and monitor actual usage via redis-cli INFO memory. Adjust upward if you see frequent evictions, or downward if usage stays well below the limit.

Does Redis cache WooCommerce product and cart data?

Redis caches WooCommerce database queries (product meta, pricing, inventory counts) but you should exclude WooCommerce session and cart groups from the cache using the ignored groups filter. Cart data is user-specific and highly dynamic; caching it in a shared object store causes session conflicts and checkout errors.

What happens to my site if Redis goes down?

WordPress gracefully degrades to its default in-memory object cache when Redis is unavailable. The site continues to function normally, just without the performance benefits of persistent caching. The timeout constants in wp-config.php (WP_REDIS_TIMEOUT and WP_REDIS_READ_TIMEOUT) control how long WordPress waits before falling back, so keep these at 1 second or less to prevent slow page loads during a Redis outage.

Similar Posts