How to Install Redis Object Cache on WordPress (VPS Setup Guide)
Redis object cache on wordpress stores repeated database results in memory, so WordPress skips work it already did. Without it, every uncached page view can repeat the same database queries for menus, widgets, options, and post data. With it, those results come back from RAM in a fraction of the time. This guide walks through a full wordpress object cache setup on a VPS: install Redis, lock it down, connect WordPress, and prove the cache is actually working.
What redis object cache on wordpress does
WordPress builds each page from database queries. An object cache sits between WordPress and the database and keeps the answers to frequent queries in memory. When the same query runs again, WordPress reads the stored answer instead of asking the database. That helps most on pages that cannot use a full page cache, such as logged-in views, WooCommerce carts, and membership pages, and on sites with complex queries from many plugins.
An object cache is not a page cache. A page cache stores finished HTML and serves it without running PHP. An object cache still runs PHP, but it cuts the database work inside that run. You usually want both: a page cache for anonymous visitors, and an object cache for the database load behind it.
Plugins can also store transients and other temporary data in Redis instead of the options table, which keeps the database smaller. That is why a redis server vps setup pays off more as a site grows: the database work it removes grows with the site.
Before you start: check RAM and PHP
Redis holds data in RAM, so check free memory before you install it. On a 1 GB VPS already running Nginx, PHP-FPM, and MySQL, Redis competes for the same small pool. It can still work with a tight memory cap, but you must set that cap, or Redis will keep growing until the server struggles. If you are unsure about sizing, review how much RAM your WordPress VPS needs and check VPS resource usage before you add another service.
You also need PHP support for Redis. Most setups use either the PhpRedis extension or the Predis library bundled with the plugin. PhpRedis is faster and is the better choice on a VPS you control. Check whether it is already installed with php -m | grep redis. If the command prints nothing, install the extension for your PHP version, for example sudo apt install php8.3-redis, then restart PHP-FPM. Replace 8.3 with the version from php -v.
Step 1: Install Redis on your VPS
On Ubuntu or Debian, install Redis from the system packages:
sudo apt update && sudo apt install redis-serversudo systemctl enable redis-server && sudo systemctl start redis-serverredis-cli ping
If the last command returns PONG, Redis is running. If it fails, check sudo systemctl status redis-server before changing anything else.
Next, lock Redis down. By default on Ubuntu, Redis listens only on localhost. Keep it that way, and never expose the Redis port to the internet. Open the config file, usually /etc/redis/redis.conf, and confirm these lines:
bind 127.0.0.1 ::1protected-mode yesrequirepass your-strong-password-here
Set a memory cap in the same file so Redis cannot grow without limit:
maxmemory 128mbmaxmemory-policy allkeys-lru
The allkeys-lru policy drops the least recently used keys when the cap is reached, which is the right behavior for a cache. A 128 MB cap suits a small VPS. After editing the config, restart Redis with sudo systemctl restart redis-server, then test the password with redis-cli -a your-strong-password-here ping.
For multi-site servers: if you run more than one WordPress site on the same Redis install, each site needs its own key prefix, or two sites can read each other’s cached data. The next step handles prefixes through a constant in wp-config.php.
Step 2: Connect WordPress with a redis wordpress plugin
The standard route is the free Redis Object Cache plugin. Install it from the WordPress admin under Plugins, or with WP-CLI:
wp plugin install redis-cache --activate
Before you enable the cache, add the connection details to wp-config.php, above the “stop editing” line:
define( 'WP_REDIS_HOST', '127.0.0.1' );define( 'WP_REDIS_PORT', 6379 );define( 'WP_REDIS_PASSWORD', 'your-strong-password-here' );define( 'WP_CACHE_KEY_SALT', 'yoursite-prefix' );
Use a distinct salt per site on a shared Redis install. The salt becomes part of every cache key, so two sites with different salts never collide. After saving wp-config.php, open Settings, then Redis, in the admin and click Enable Object Cache. The plugin copies a drop-in file into wp-content/object-cache.php, which is what hooks WordPress into Redis. If it cannot write the drop-in, check file ownership on wp-content: the web server user must be able to write there.
If you migrated WordPress to a VPS recently, this is a good moment to add Redis, because you now control the server packages and the wp-config.php file directly. On shared hosting, Redis is often unavailable or shared with other customers, so a VPS is where this setup makes practical sense.
Step 3: Test that the cache is actually working
Do not trust the plugin status page alone. A green status line only means the connection works. Prove that caching happens by checking Redis itself. First, visit several pages on your site, including a logged-in view, then run:
redis-cli -a your-strong-password-here info stats
Look for keyspace_hits and keyspace_misses. Hits should climb as you revisit pages. If hits stay at zero while misses grow, WordPress is writing but never reading back, which points to a prefix or drop-in problem. Also check redis-cli -a your-strong-password-here dbsize. A count of zero after browsing means the drop-in is not active, even if the plugin page looks fine.
For a live view, run redis-cli -a your-strong-password-here monitor in one terminal while you load a page in a browser. You should see GET and SET commands flowing. Press Ctrl+C to stop it, and never leave it running unattended on a busy server.
Finally, test a content change end to end. Edit a post, publish it, and confirm the live page shows the new content. If old content sticks around, flush the cache once from the plugin page and retest.
Common pitfalls
The most frequent failure is no password on a Redis port that something else can reach. On a single VPS with localhost binding, the risk is low, but the moment you move Redis to a separate server or open a firewall port, a password becomes mandatory. Set it before you need it, not after.
Another pitfall is forgetting the cache after a migration or a restore. If you restore a database backup onto a server with a warm Redis cache, old entries can mask the restored data until they expire. Flush Redis after a restore, a site move, or a domain change, from the plugin page or with redis-cli -a your-strong-password-here flushall when no other site shares that Redis install. On shared installs, flushall clears every site, not only yours.
Plugin conflicts cause a third class of problems. Some caching plugins ship their own object cache drop-in, and two drop-ins cannot both live in wp-content/object-cache.php. If you already use a full caching plugin with object cache support, pick one object cache path and disable the other. A wordpress caching plugin handles page HTML, Redis handles database objects, and they complement each other when each one owns its own layer.
Finally, check the common VPS setup mistakes list if Redis refuses to start after a reboot. The usual culprits are a config typo, a wrong file permission on the Redis data directory, or a memory cap set higher than the RAM the server can spare.
When Redis will not help much
Redis gives the least benefit on a tiny site with a good page cache, because anonymous visitors never reach the database layer anyway. It also will not fix a slow theme, unoptimized images, or a plugin that runs expensive remote requests on every page load. Add it when you see real database load: slow logged-in pages, heavy WooCommerce queries, or a query count that stays high after page caching is on.
When the setup is done and tested, leave the memory cap and password in place, and add a Redis check to your normal server routine: a quick redis-cli ping and a glance at memory use during your regular maintenance pass.