How to Speed Up WordPress with Redis Object Caching on Your VPS

Open a WordPress page and the server runs a chain of database queries before anything renders: posts, menus, widgets, options, user data. On a small VPS that chain is often the slowest part of the page. Redis object caching WordPress setups break it by keeping query results in memory, so repeat requests read from RAM instead of hitting MySQL again.

Pages that used to wait on the database get their data in microseconds instead, and the database gets room for the queries that need fresh answers. This guide covers the full path: checking your VPS, installing Redis, connecting WordPress, and proving the cache works, plus the mistakes that turn it into a slowdown.

Redis Object Caching WordPress Basics: What Gets Cached

WordPress already has an object cache, but by default it lives only for a single request, so every page load rebuilds it from scratch: the same options, menu items, and user metadata, queried again and again. A persistent object cache stores those results somewhere that survives between requests. Redis is that somewhere.

What lands in Redis is the small, repeatable stuff: option values, transients, user meta, term data, and common query results. Rendered HTML does not; that belongs to page caching, a separate layer. A Redis cache for WordPress speeds up the database work behind a page, not the delivery of the finished page.

Take a site menu with twenty items spread across several tables. Without an object cache, WordPress queries those tables on every page load; with Redis, the first load stores the result and the next thousand read it from memory.

Check Your VPS Before You Install Redis

Redis stores everything in RAM, so the first check is memory. Run free -h and look at what is actually available after MySQL and PHP take their share. On a 1 GB VPS the margin is thin, so cap how much memory Redis can use. A small site runs fine with a 64 MB or 128 MB limit, which you can raise later as traffic grows.

Next, check whether Redis is already running: redis-cli ping answers PONG when a server is up. If it answers, skip the install and go straight to locking it down and connecting WordPress. If the command is not found, nothing is installed yet.

Back up the site first. A Redis install rarely breaks WordPress, but a wrong line in wp-config.php can white-screen it, and restoring from a backup beats debugging a live site at midnight.

How to Set Up Redis Object Caching on Your VPS

A typical WordPress Redis setup takes under half an hour once Redis is installed. The steps below assume Ubuntu or Debian and a WordPress install managed over SSH.

Step 1: Install Redis

Install from your distribution packages so security updates arrive with the rest of the system:

sudo apt update && sudo apt install redis-server -y
sudo systemctl enable --now redis-server
redis-cli ping

That last command should print PONG, which means the server is running on its default port, 6379.

Step 2: Lock Redis Down

A fresh Redis install listens on localhost with no password, which is fine on a single-server VPS and dangerous anywhere else. In /etc/redis/redis.conf confirm three settings: bind 127.0.0.1, protected-mode yes, and a requirepass value you generate yourself. Then cap its memory so it can never starve MySQL:

maxmemory 128mb
maxmemory-policy allkeys-lru

The allkeys-lru policy drops the least recently used keys when Redis hits the cap, instead of refusing new writes. Our guide to installing and securing Redis covers the rest: firewall rules and disabling commands you will never use.

Step 3: Install the Redis Object Cache Plugin

Install the free Redis Object Cache plugin by Till Krüss from the dashboard or with WP-CLI:

wp plugin install redis-cache --activate

Our full Redis Object Cache plugin setup walkthrough covers the dashboard path in detail. Do not click Enable yet; WordPress needs the connection details first.

Step 4: Connect WordPress to Redis

Add these lines to wp-config.php, above the line that says “That’s all, stop editing!”:

define( 'WP_REDIS_HOST', '127.0.0.1' );
define( 'WP_REDIS_PORT', 6379 );
define( 'WP_REDIS_PASSWORD', 'your-redis-password' );
define( 'WP_CACHE_KEY_SALT', 'yoursite_' );

The key salt matters when one Redis server serves more than one site; without it, two sites can read each other’s cached objects and serve the wrong menus and widgets. Then enable the cache:

wp redis enable

This drops an object-cache.php file into wp-content, the bridge that replaces the built-in object cache with the Redis-backed one. The plugin settings page should now report Status: Connected.

Step 5: Confirm the Connection Holds

Load a few pages, then run wp redis status. It reports the Redis version, keys stored, and whether the connection is live. An error usually means a wrong password in wp-config.php, Redis bound to the wrong address, or a firewall rule blocking port 6379 on loopback.

How to Tell If the Object Cache Is Actually Working

Connected does not mean effective. The number that matters is the hit rate, found in redis-cli info stats as keyspace_hits and keyspace_misses: divide hits by hits plus misses. A healthy WordPress object cache settles well above 80 percent after a day of traffic.

A hit rate near zero after real traffic means something is wrong: the plugin may be enabled but not connected, or another plugin is bypassing the cache with direct database calls. Use Query Monitor to compare the query count on a repeat page load before and after enabling Redis; repeat loads should run noticeably fewer queries.

For a quick live look, redis-cli monitor streams every command Redis receives. Run it, load a page, watch the GET and SET commands flow, then close it with Ctrl+C. Never leave it running; it slows Redis down while it streams.

What Redis Will Not Fix

Redis fixes repeated database reads, and expecting it to fix the rest of the stack is the most common disappointment after setup.

A slow theme still renders slowly, and a plugin that fires heavy queries on every load still fires them; Redis only helps when the same query repeats. Dynamic pages like a WooCommerce cart or checkout skip the cache by design, and an oversized wp_options table full of autoloaded junk still loads on every request. Start with cleaning up revisions and transients that slow down your site before blaming Redis for a page that stays slow.

Page caching is the other half of the job: Redis trims the work behind a page, while a page cache or CDN serves the finished page without touching PHP. Most fast WordPress sites on a VPS run both.

When Redis Makes Your Site Slower

Redis adds a network round trip to every cache lookup. On a hit that trip costs almost nothing; on a miss WordPress pays the trip and then runs the database query anyway. A site with a near-zero hit rate is slower with Redis than without it, which is why measuring the hit rate matters more than installing the plugin.

Memory is the other trap. On a 1 GB VPS, an uncapped Redis grows until the system starts swapping, and a swapping server is slower than one without any cache. The maxmemory cap from Step 2 prevents this. If the admin area still drags, the bottleneck is usually elsewhere; see our guide on a slow WordPress admin dashboard for where to look next.

Redis vs Memcached: Which One Belongs on Your VPS

Memcached does the same job with a simpler design: pure in-memory storage, no persistence, fewer features. Redis adds data structures and optional persistence to disk. For a WordPress site on a VPS, Redis is the common pick because its persistence survives a restart, so the cache warms up faster instead of starting empty.

Memcached is still a fair choice when you want the smallest moving part and no persistence. Our Redis vs Memcached comparison for WordPress object caching breaks down the trade-offs, including memory behavior and plugin support.

Frequently Asked Questions

Does Redis replace my page caching plugin? No. Redis caches database objects; a page caching plugin caches finished HTML pages. They solve different problems and work best together.

How much RAM should I give Redis? Start small: 64 MB to 128 MB covers most small WordPress sites. Watch used_memory_human in redis-cli info memory, and raise the cap only when evictions climb.

Will Redis speed up WooCommerce? Partly. Catalog browsing and admin queries repeat the same lookups, so they get faster. Cart and checkout stay dynamic and bypass the object cache, so they see no benefit.

Do I need Redis if I already use a CDN? Yes. A CDN caches finished pages at the edge, while Redis trims database work for pages it cannot cache, like logged-in views and admin screens.

Install Redis, connect the plugin, and check the hit rate after a day of traffic. If the rate climbs and database load drops, the cache earns its memory. If not, the problem sits somewhere Redis cannot reach.

Ditulis oleh

Firdaus Safari Putra

Founder, PT FirKaizen Digital Solutions

Firdaus Safari Putra adalah founder PT FirKaizen Digital Solutions. Ia membangun dan mengoperasikan infrastruktur server di balik panduan ini, dan menulis berdasarkan apa yang benar-benar ia jalankan, uji, dan ukur — bukan teori.