Skip to content

How to Install Redis and Enable Object Cache to Speed Up WordPress

A practical guide to installing Redis on a VPS and enabling a persistent object cache for WordPress: how it differs from page caching, installation and hardening steps on Ubuntu/Debian, configuring the wp-config constants, and verifying that the cache actually works — to take load off the database and speed up dynamic and logged-in requests.

VPSمريم العتيبي33 min read
Illustration of object cubes on a memory stick serving a site quickly while a database is bypassed, representing an in-memory object cache
On this page

This guide covers the side you won't find in the usual WordPress caching articles: setting up the server itself. If you want to speed up your site with plugin-level page caching, see How to speed up WordPress with a cache plugin, and if you want to compare plugins, see WP Rocket, W3TC or LiteSpeed?. Here we assume your page cache is already configured, and we add the layer that works beneath it: an object cache backed by Redis. This is a server-level task that requires root access and an SSH connection, and it usually can't be done on cheap shared hosting because it doesn't let you install system services.

What is an object cache and why does WordPress need it?

To understand the value of an object cache, you first need to understand how WordPress builds a single page. When a visitor requests a page, WordPress doesn't read a ready-made file; it runs PHP code that sends a series of queries to the MySQL database: fetch the site settings, fetch the post, fetch the comments, fetch the menus, fetch the widgets, fetch the data for every active plugin. An ordinary page can generate between twenty and a hundred queries, and a store or membership page can easily exceed three hundred. Each query is a small trip to the disk, an internal network and a database engine, and they all add up in PHP processing time.

Here is the key observation: many of these queries repeat with identical results. The same site settings are fetched on every request. The same category list. The same theme options. There is no point asking MySQL "what is the site name?" millions of times a day when the answer hasn't changed in months. An object cache solves exactly this: it saves the result of a query in fast memory, so when the same query is requested again, the result is served straight from memory without touching MySQL. The outcome is fewer actual queries against the database and less pressure on the slowest link in the system.

WordPress already has an API for this purpose called WP_Object_Cache, which the core and plugins use through functions such as wp_cache_get and wp_cache_set. The problem lies in the default implementation, not in the idea.

This is the difference between an "object cache" and a "persistent object cache." The first always exists and offers little benefit between requests. The second requires an external store that lives independently of the request lifecycle — a service that stays in memory on the server, keeping the stored results to serve the next request, and the one after it, for hours. That store is what we will install: Redis. Once we connect it, the same WP_Object_Cache interface — without changing any theme or plugin code — turns from transient memory into a real persistent cache, because the plugin replaces only the backend layer.

Object cache vs. page cache: two different layers

The biggest confusion among beginners is mixing up the two types, or thinking one replaces the other. In reality, they work in two completely different layers of the request cycle, store different things in different places, and don't compete — they complement each other.

Cache layers: where is the request caught?BrowserBrowserEdge / CDNEdgePage cachePageObject cacheObjectDatabaseOriginA hit at any layer ⟸ instant response, journey ends
Cache layers in order: the earlier the layer where the request is hit (far right), the faster the response returns without reaching the database.

A page cache works at the top of the stack: it intercepts the request before PHP runs and serves a complete, ready-made HTML copy. On a hit, PHP doesn't run and MySQL isn't touched at all — the fastest path possible. But it only works for pages that can be shared as-is among many visitors, meaning logged-out visitors. The moment a user logs in, adds a product to their cart, or opens their membership dashboard, their page becomes personalized and can't be served from a shared static copy — so the page cache is bypassed entirely and WordPress goes back to building the page from scratch.

This is where the object cache comes in. It works at the heart of page building, not above it: when WordPress builds a page (because it wasn't cached or because the visitor is logged in), the object cache intercepts individual database queries and serves the ones it has already stored. In other words, it speeds up exactly the requests that a page cache cannot touch. That is why they complement each other: the page cache catches anonymous visitors (most of the traffic on a typical blog), and the object cache lightens the load of dynamic requests (most of the traffic on a store or membership platform).

CriterionPage cacheObject cache
What does it store?A complete, built HTML pageResults of individual MySQL queries
Where does it work?Top of the stack — before PHPInside page building — between PHP and MySQL
Who benefits?Logged-out visitorsEvery dynamic request (logged-in, store, dashboard)
Where is it stored?A file on disk or memoryMemory (Redis / Memcached)
Does it bypass MySQL?Completely, on a hitPartially — it reduces the number of queries
Biggest impact onTTFB of public pagesPHP processing time of dynamic pages
Server requirementsUsually none (the plugin manages it)An installed in-memory service (Redis)

The rule of thumb: if your site is a blog or a brochure site that serves anonymous visitors, a page cache alone gives you most of the gain, and an object cache is a marginal improvement. But the higher the share of requests that can't be cached as a whole — a store, memberships, a forum, dashboards — the more valuable an object cache becomes, until it is a necessity rather than a luxury.

What is Redis and why does it suit WordPress?

Redis (short for Remote Dictionary Server) is an in-memory data store that stores key/value pairs and returns them with response times measured in fractions of a millisecond. Because it keeps data in RAM instead of on disk, it is orders of magnitude faster than any traditional database query. That is exactly what makes it ideal as the backend for an object cache: we want a place to put query results and retrieve them as fast as possible, and Redis's memory does just that.

You might ask: why Redis and not Memcached? Both are valid in-memory stores for a WordPress object cache, and both are supported by plugins. The practical difference is that Redis is richer: it supports more data types, multiple memory eviction policies, and an optional ability to save data to disk so it survives a restart. On top of that, the most popular WordPress plugin, "Redis Object Cache," is built around it. Memcached is simpler and slightly lighter, but less flexible. For most WordPress sites on a VPS, Redis is the sensible default, and it is what this guide is built on.

Object cache path through RedisWordPress / PHPRequests a query resultRedis · memoryHit or miss?MySQLDatabaseHit: instant response from memoryMissFetched from MySQL, stored in Redis, returned
The object cache path: WordPress asks Redis first — a hit is returned immediately from memory and bypasses MySQL; a miss is fetched from MySQL, the result is stored in Redis, then returned.

The mechanism shown in the diagram above is simple, and it is important to grasp it before installing. When WordPress needs a query result, it asks Redis first: "Do you have the result of this query?" If it exists (a hit), Redis returns it immediately from memory, and WordPress skips hitting MySQL entirely for that query — the fast path. If it doesn't exist (a miss), WordPress goes to MySQL as usual, fetches the result, stores it in Redis for next time, then returns it — the slow path, which happens once per unique query. Over time, as hits accumulate, the number of actual queries against MySQL drops noticeably.

Prerequisites: why do you need a VPS?

Before we touch any command, we need to clarify a basic requirement that is often overlooked: this procedure requires a server where you have root access and an SSH connection. The reason is straightforward — we will install a system service (the Redis server), edit system-level configuration files, and restart PHP services. All of these are operations that need administrative privileges that cheap shared hosting doesn't grant, because it is an isolated environment that doesn't let you install services running in the background.

This is the essential difference between the two halves of an object cache: the "Object Cache" option you see in cache plugins refers to the software layer inside WordPress, but it doesn't do anything real unless there is an actual memory server behind it. On cheap shared hosting, that server is usually missing, so you click the button and nothing changes. On a VPS, you are the one who installs that server — which is why this task is by nature a VPS task. If you don't have a server yet, start with setting up your first VPS, and because all the installation commands below are run through a remote terminal, make sure you are comfortable with SSH basics for beginners before continuing.

In short, before you start, make sure you have:

  • A VPS running a recent version of Ubuntu or Debian, with sudo privileges.
  • A working SSH connection to the server.
  • WordPress installed and running on it, with PHP-FPM (not the old mod_php in the examples here).
  • A recent backup — any change to wp-config.php or system services deserves a copy you can roll back to.

Some managed WordPress hosting environments offer Redis ready to use as an enabled feature, in which case you skip the server installation section and jump straight to installing the plugin and configuring wp-config. But if you manage a VPS yourself, the full path below is your route.

Step 1: Install the Redis server on Ubuntu/Debian

We start by connecting to the server over SSH, then update the package index and install the Redis server. The official Ubuntu and Debian repositories provide a ready-made redis-server package, which is perfectly sufficient for a WordPress object cache — no need for third-party repositories:

bash
sudo apt update
sudo apt install redis-server -y

Once installation finishes, the Redis service starts automatically. Verify that it is running with a simple command that asks it for a live reply:

bash
redis-cli ping

If you see the reply PONG, the Redis server is running and responding. That is the first small win: you now have an in-memory store running on the server. But before we connect it to WordPress, there are two critical steps: securing it, then giving it the PHP extension that talks to it. Don't skip the security step — by default, Redis is designed to trust the local network, and leaving its default configuration on an internet-connected server is a common and costly security mistake.

We will edit the main Redis configuration file, which on Ubuntu/Debian is located at /etc/redis/redis.conf. Open it with an editor such as nano:

bash
sudo nano /etc/redis/redis.conf

We will change three things in it over the next steps: binding the listener to localhost only, configuring memory behavior, and integrating it with the service manager. Let's start with the most important one for security.

Step 2: Secure Redis — never expose it to the internet

This is the most dangerous step if neglected, and the simplest if understood. In its simple default mode, Redis doesn't have a strong authentication layer, and its original philosophy is that it runs inside a trusted network behind a firewall. That is why its port (6379) must never be open to the public internet. An unprotected Redis server exposed to the internet is an easy target: an attacker connects to it, reads your stored data, or worse — exploits it to run commands on your server. Many breaches are directly caused by an exposed Redis instance.

The first and most important protection is binding to localhost only. Since WordPress runs on the same server as Redis, there is no need at all for Redis to listen on any external network interface — it only needs to listen for connections coming from inside the server itself. In the configuration file, find the bind line and make sure it is set like this:

bash
bind 127.0.0.1 ::1

This restricts Redis to listening on the local loopback address only (IPv4 and IPv6), making it completely invisible to any machine outside the server. In most Ubuntu/Debian packages this is already the default, but check for yourself — don't assume. Also make sure protected-mode is set to yes (the default), as it provides an extra layer of security that rejects external connections if no authentication is configured.

The second, optional layer is a password (requirepass). With local-only binding, a password becomes less urgent, because no one outside the server can reach Redis in the first place. But it is still useful defense in depth, especially on a server with multiple users or one where you run several applications. To enable it, find the requirepass line in the configuration file, uncomment it, and set a strong random password:

bash
requirepass a_long_random_password_here

Generate a strong password with a command such as openssl rand -base64 32 and put it here. Save this password, because you will need it in wp-config.php later. After any change to the configuration file, save the file and exit, then restart Redis to apply the changes:

bash
sudo systemctl restart redis-server

A final security tip: even with local binding, have the firewall on your server (such as ufw) explicitly block port 6379 from the outside as a backup layer. Good security comes in layers, not reliance on a single setting.

Step 3: Install the PHP extension and connect the service

The Redis server is now running and secured, but WordPress (which is PHP code) doesn't yet know how to talk to it. The bridge between them is a PHP extension for Redis called phpredis. Without it, you will install the plugin and set the constants, but it won't connect and will complain that the "Redis extension is not found." Installing it on Ubuntu/Debian is simple with the package manager:

bash
sudo apt install php-redis -y

The php-redis package binds itself to the system's default PHP version. If you run a specific PHP version (which is common), explicitly install the package that matches your version — replace 8.3 with your actual version:

bash
sudo apt install php8.3-redis -y

After installing the extension, you must restart PHP-FPM so it loads the new extension. Many people miss this step and are left puzzled about why the connection doesn't work even though everything is installed: the extension isn't loaded into running processes, only when a new process starts. Restart the PHP-FPM service that matches your version:

bash
sudo systemctl restart php8.3-fpm

To verify that the extension is actually loaded, ask PHP for its list of modules and look for redis:

bash
php -m | grep redis

If the word redis appears in the output, the bridge is ready. We now have a running, secured Redis server and a PHP extension that knows how to talk to it. One last piece remains — WordPress itself — so let's connect it.

Step 4: Install the Redis Object Cache plugin and configure wp-config

On the WordPress side, you don't need to write any code. The most popular and most trusted plugin for this task is "Redis Object Cache" by Till Krüss, with more than a hundred thousand active installations. Its job is to create the drop-in file that switches the WordPress WP_Object_Cache interface to use Redis instead of transient memory. Install it like any plugin: from the WordPress dashboard, go to Plugins > Add New, search for "Redis Object Cache," install it and activate it. Don't click "Enable" yet — first we need to tell WordPress where to find Redis.

This is where the wp-config.php file comes in: the main WordPress configuration file in the root of the installation. We will add a set of WP_REDIS_* constants that tell the plugin the Redis address, its port, its password, and the database number to use. Placement matters: these constants must be above the line that says /* That's all, stop editing! */ and before wp-settings.php is loaded, otherwise WordPress won't read them. Add the following block:

php
define( 'WP_REDIS_HOST', '127.0.0.1' );
define( 'WP_REDIS_PORT', 6379 );
define( 'WP_REDIS_DATABASE', 0 );

// Add the next line only if you set requirepass in step 2
define( 'WP_REDIS_PASSWORD', 'the_same_password_you_set' );

Note that WP_REDIS_HOST is exactly 127.0.0.1 — the same localhost address we restricted Redis to, which confirms that WordPress and Redis are on the same server. As for WP_REDIS_PASSWORD, add it only if you enabled requirepass; if you didn't set a password, delete this line entirely, or the connection will fail. The following table summarizes the most important constants:

ConstantTypical valuePurpose
WP_REDIS_HOST127.0.0.1Redis server address — always localhost in this setup
WP_REDIS_PORT6379Default Redis port
WP_REDIS_PASSWORDThe passwordAuthentication — add it only if you set requirepass
WP_REDIS_DATABASE0Redis database number (0–15) to isolate the cache from other applications
WP_REDIS_PREFIXA unique stringKey prefix — useful for isolating several sites that share one Redis
WP_REDIS_TIMEOUT1Connection timeout in seconds — prevents the site from hanging if Redis fails
WP_REDIS_SCHEMEunixUse unix with WP_REDIS_PATH to connect over a socket instead of TCP

After saving wp-config.php, go back to the WordPress dashboard: Settings > Redis (or the plugin's page). You will see the connection status and an "Enable Object Cache" button. Click it. The plugin now copies the object-cache.php file into the wp-content/ folder; this is the drop-in that intercepts all object cache calls and routes them to Redis. If everything worked, the status will change to a green "Connected".

Step 5: Verify that the cache actually works

"Connected" means WordPress successfully connected to Redis, but on its own it doesn't prove that the cache is working and getting hits. To make sure, we have three complementary tools. The first is inside the plugin itself: its page shows live metrics — the number of hits and misses, the hit ratio, and the amount of memory used. As you browse the site, you should see the hit counter rise and the hit ratio gradually approach high values (above 90% on a stable site). A high hit ratio is direct evidence that Redis is actually serving queries.

The second tool is monitoring Redis directly from the terminal. The monitor command shows every command that reaches Redis in real time:

bash
redis-cli monitor

Run it, then open your site or refresh a page in another browser: you will see a stream of GET and SET commands flowing in immediately, which is live proof that WordPress is talking to Redis on every request. (Stop it with Ctrl+C, and don't leave it running in production, because it consumes resources.) The third tool is the INFO command, which gives a comprehensive statistical snapshot of the server's state — memory usage, number of keys, hit ratios, uptime:

bash
redis-cli info stats
redis-cli info memory

Watch keyspace_hits and keyspace_misses in the stats section in particular: over time, hits should grow much faster than misses. If you see keys accumulating, memory growing and hits rising, the object cache is working as it should. Finally, the only real measure is performance: measure the processing time of a dynamic page (such as a store cart or a membership dashboard) before and after enabling it — you should see a drop in the number of database queries and in build time.

Step 6: Fine-tuning — memory, eviction and persistence

The default configuration works, but a little tuning turns it from "works" into "works well under pressure." The two most important settings here are the memory limit (maxmemory) and the eviction policy (maxmemory-policy), both in /etc/redis/redis.conf.

The problem they solve: Redis stores everything in RAM, and without a limit it will keep consuming memory until the server's RAM runs out entirely, at which point the system kills other processes (including MySQL or PHP) — a performance disaster. The solution is to give Redis a memory ceiling and tell it what to do when it fills up. Find the following two lines and set them:

bash
maxmemory 256mb
maxmemory-policy allkeys-lru

The maxmemory value depends on your server's RAM and the number of sites; 256 MB is a reasonable starting point for a medium-sized site, and you can raise it on a bigger server or for a site with a huge cache. maxmemory-policy is the more important one: the allkeys-lru policy is the right choice for a WordPress cache. It means: when memory fills up, evict the least recently used keys to make room for new ones. This is ideal cache behavior — we get rid of cold data and keep the hot data. Avoid the default noeviction policy for a cache, because it rejects writes when memory is full, so caching stops and WordPress logs errors.

The third useful setting is the database number (WP_REDIS_DATABASE). Redis divides itself into numbered databases (0 to 15 by default), which are isolated namespaces. If your server runs other applications that use Redis, or several WordPress sites, give each one a different number (for example, one site on 0 and another on 1) to separate their caches. That way, flushdb clears one site's cache without touching the other. Instead of, or in addition to, this, use WP_REDIS_PREFIX to give each site a unique key prefix.

Persistence is a trade-off. Redis can periodically save its contents to disk (via RDB or AOF) so they survive a restart. But for a WordPress cache specifically, persistence is usually unnecessary and can even hurt: the stored data is just a cache that can be rebuilt from MySQL at any moment, so nothing is really lost if it disappears on restart — it will gradually refill from the first requests. And constantly writing the cache to disk adds I/O overhead with little benefit. Many engineers disable persistence on a Redis instance dedicated solely to caching to get maximum speed. If you use the same Redis instance for other important data, that is a different matter — but for a pure cache, speed matters more than survival.

Troubleshooting

Most object cache problems with Redis fall into a handful of recurring patterns, and the fixes are straightforward once you know the cause. The following table collects the most common issues:

SymptomLikely causeFix
The plugin shows "Not connected"Redis is stopped, or the host/port is wrongCheck redis-cli ping; review WP_REDIS_HOST and WP_REDIS_PORT
«PhpRedis extension not found»The PHP extension isn't installed or PHP-FPM wasn't restartedInstall phpX.Y-redis and restart PHP-FPM; check php -m | grep redis
«NOAUTH Authentication required»Redis requires a password and WordPress doesn't send itAdd WP_REDIS_PASSWORD with the same value as requirepass
Connected, but the hit ratio is zeroThe object-cache.php drop-in is missing or disabledClick "Enable" again; make sure wp-content/object-cache.php exists
Old content appears after an updateA stale cache that wasn't invalidated"Flush Cache" or redis-cli flushdb
The site is slow or sometimes hangsRedis is full with the noeviction policy, or the timeout is longSet allkeys-lru, and add a short WP_REDIS_TIMEOUT
"Connection refused" on the portRedis listens on a Unix socket, not TCP, or bind is wrongReview bind, or use WP_REDIS_SCHEME and WP_REDIS_PATH

An important diagnostic point: always work from the bottom of the stack up. First check that Redis is running (redis-cli ping), then that the extension is loaded (php -m | grep redis), then that the constants in wp-config.php are correct, and finally the plugin's status. This order isolates the problem quickly instead of guessing. And if strange visual or functional behavior suddenly appears after everything was working, the first suspect is a stale cache — try flushdb before any deeper diagnosis, as it resolves a large share of cases immediately.

Another common error comes from updating WordPress or plugins: sometimes the object-cache.php drop-in from an old version of the plugin remains after it is updated and causes a conflict. The fix is to disable the cache and then re-enable it from the plugin's page, which rewrites the file with its new version. And if you are moving a site between servers, remember that object-cache.php points to a local Redis — on a new server that doesn't have Redis, delete this file or disable the plugin first so the site doesn't break.

When does an object cache really help, and when is a page cache enough?

Now that you have mastered the installation, the practical question is: does your site even need this effort? The honest answer is that it depends on the nature of your site; it is not an absolute "yes." An object cache delivers the biggest return when a high share of your requests are dynamic — that is, they can't be served from a page cache. The more of them there are, the more valuable it becomes.

The sites that benefit the most:

  • WooCommerce stores: every user has a cart and a session, and the cart, account and checkout pages can't be cached as a whole and generate many queries. Here, an object cache takes real load off MySQL with every purchase interaction.
  • Membership sites: protected, subscriber-specific content bypasses the page cache, so the object cache becomes the main speedup available.
  • Forums and communities: millions of queries on posts, users and notifications, and a high share of logged-in users.
  • Large, high-traffic sites: even a huge blog benefits when the query count piles up and the database approaches its capacity limits.

By contrast, an ordinary blog or brochure site that serves anonymous visitors usually gets most of the gain from a page cache alone, and an object cache is a marginal improvement that doesn't always justify managing an extra service. And don't forget that an object cache is no substitute for a clean database: a database bloated with revisions and transients stays slow even with Redis. See How to clean up and optimize your WordPress database — the two layers complement each other: cleanup reduces the size of each query, and caching reduces how often it repeats. For a deeper understanding of the different types of caching and where they sit, see Caching explained.

The important realistic expectation: an object cache reduces database load and speeds up dynamic and logged-in requests, but it is no substitute for a page cache, and it won't turn a site that is slow for other reasons (weak hosting, huge images, a heavy theme) into a fast one. It is a precise tool for a specific problem — repeated MySQL hits — not an all-purpose magic wand.

Conclusion

A Redis-backed object cache is the layer that complements a page cache where the latter falls short: while a page cache serves anonymous visitors with ready-made HTML copies, an object cache takes load off the database on dynamic requests that can't be cached as a whole — the store cart, the member dashboard, logged-in pages. The key point that must stay clear: the two layers are different and complementary, and the built-in WordPress object cache has no real benefit until you put a persistent store such as Redis behind it.

In practice, the full path goes through connected steps: installing the Redis server and securing it with local-only binding (the most dangerous thing to neglect), installing the PHP extension and restarting PHP-FPM, connecting WordPress through the Redis Object Cache plugin and the WP_REDIS_* constants in wp-config.php, then verifying with live tools (the plugin's metrics, monitor, INFO), and finally tuning with a memory limit and the allkeys-lru eviction policy. Each step builds on the previous one, and diagnosis always starts from the bottom of the stack. Apply this on a well-prepared VPS, and you will give your dynamic site a speedup that a page cache alone can't deliver — as long as you remember that it is a complement, not a replacement.

Frequently asked questions

What is the difference between object cache and page cache? A page cache stores a complete HTML page and serves it to logged-out visitors, bypassing PHP and MySQL entirely. An object cache stores the results of individual database queries in memory and speeds up building dynamic pages that cannot be cached as a whole (stores, logged-in users). They are two different layers, and it is best to use both together.

Do I need a VPS to enable a persistent object cache? In practice, yes, if you want to install Redis yourself, because it is a system service that requires root access and an SSH connection, which cheap shared hosting does not provide. The exception is managed WordPress hosting that offers Redis ready to use as a feature — in that case you skip the server installation and connect the plugin directly.

Why does the plugin say "Connected" but performance doesn't change? Check the hit ratio in the plugin's metrics: if it is zero or very low, the object-cache.php drop-in may be missing or disabled. Click "Enable" again and make sure the file exists in wp-content/. Also remember that the effect of object caching shows up mainly on dynamic pages, not on static pages that are already page-cached.

Is Redis better than Memcached for WordPress? Both are valid in-memory stores and both are supported by WordPress plugins. Redis is richer in features (more data types, multiple eviction policies, optional persistence) and the most popular plugin is built around it, so it is the sensible default for most sites. Memcached is simpler and slightly lighter, but less flexible. For most sites the practical difference is small.

How can I confirm that the object cache is actually working? Three tools: the plugin's metrics (watch the hit ratio rise), the redis-cli monitor command, which shows GET/SET commands streaming with every request, and the redis-cli info stats command to compare keyspace_hits against keyspace_misses. The ultimate measure is a drop in the number of database queries and in the build time of dynamic pages.

Should I set a password for Redis? When Redis is bound to localhost only (bind 127.0.0.1), a password is less urgent because no one outside the server can reach Redis. But it is useful defense in depth, especially on a server with multiple users or applications. If you enable it with requirepass, add WP_REDIS_PASSWORD with the same value in wp-config.php.

What should I do if old content appears after updating a theme or plugin? Flush the cache: click "Flush Cache" on the plugin's page, or run redis-cli flushdb in the terminal (it clears only the current Redis database). A stale cache after updates is a common cause of sudden visual or functional glitches, and clearing it is the first thing to try.

What is the right memory policy for Redis with WordPress? Set maxmemory to a reasonable limit (256 MB is a good starting point) and maxmemory-policy allkeys-lru. The latter evicts the least recently used keys when memory fills up — ideal cache behavior. Avoid noeviction, because it rejects writes when memory is full, so caching stops and errors appear.

Do I need to enable persistence in Redis? For a pure cache, usually not. The stored data is just a cache that can be rebuilt from MySQL, so nothing is really lost if it disappears on restart — it gradually fills up again. Disabling persistence saves I/O overhead and increases speed. If you use the same Redis instance for other important data, that is a different story.

Does an object cache replace a page cache? No. They are two different layers: a page cache speeds up anonymous visitors with ready-made HTML copies, and an object cache speeds up dynamic requests by reducing database hits. It is best to run both together. An object cache alone will not speed up your public pages the way a page cache does, and vice versa.

Sources

Frequently asked questions

What is the difference between object cache and page cache?

A page cache stores a complete HTML page and serves it to logged-out visitors, bypassing PHP and MySQL entirely. An object cache stores the results of individual database queries in memory and speeds up building dynamic pages that cannot be cached as a whole (stores, logged-in users). They are two different layers, and it is best to use both together.

Do I need a VPS to enable a persistent object cache?

In practice, yes, if you want to install Redis yourself, because it is a system service that requires root access and an SSH connection, which cheap shared hosting does not provide. The exception is managed WordPress hosting that offers Redis ready to use as a feature — in that case you skip the server installation and connect the plugin directly.

Why does the plugin say "Connected" but performance doesn't change?

Check the hit ratio in the plugin's metrics: if it is zero or very low, the object-cache.php drop-in may be missing or disabled. Click "Enable" again and make sure the file exists in wp-content/. Also remember that the effect of object caching shows up mainly on dynamic pages, not on static pages that are already page-cached.

Is Redis better than Memcached for WordPress?

Both are valid in-memory stores and both are supported by WordPress plugins. Redis is richer in features (more data types, multiple eviction policies, optional persistence) and the most popular plugin is built around it, so it is the sensible default for most sites. Memcached is simpler and slightly lighter, but less flexible. For most sites the practical difference is small.

How can I confirm that the object cache is actually working?

Three tools: the plugin's metrics (watch the hit ratio rise), the redis-cli monitor command, which shows GET/SET commands streaming with every request, and the redis-cli info stats command to compare keyspace_hits against keyspace_misses. The ultimate measure is a drop in the number of database queries and in the build time of dynamic pages.

Should I set a password for Redis?

When Redis is bound to localhost only (bind 127.0.0.1), a password is less urgent because no one outside the server can reach Redis. But it is useful defense in depth, especially on a server with multiple users or applications. If you enable it with requirepass, add WP_REDIS_PASSWORD with the same value in wp-config.php.

What should I do if old content appears after updating a theme or plugin?

Flush the cache: click "Flush Cache" on the plugin's page, or run redis-cli flushdb in the terminal (it clears only the current Redis database). A stale cache after updates is a common cause of sudden visual or functional glitches, and clearing it is the first thing to try.

What is the right memory policy for Redis with WordPress?

Set maxmemory to a reasonable limit (256 MB is a good starting point) and maxmemory-policy to allkeys-lru. The latter evicts the least recently used keys when memory fills up — ideal cache behavior. Avoid noeviction, because it rejects writes when memory is full, so caching stops and errors appear.

Do I need to enable persistence in Redis?

For a pure cache, usually not. The stored data is just a cache that can be rebuilt from MySQL, so nothing is really lost if it disappears on restart — it gradually fills up again. Disabling persistence saves I/O overhead and increases speed. If you use the same Redis instance for other important data, that is a different story.

Does an object cache replace a page cache?

No. They are two different layers: a page cache speeds up anonymous visitors with ready-made HTML copies, and an object cache speeds up dynamic requests by reducing database hits. It is best to run both together. An object cache alone will not speed up your public pages the way a page cache does, and vice versa.