Server rack with glowing lights in a data center representing Redis cache setup for WordPress
CDN & Caching Strategies - Server & Hosting Tuning

How to Set Up Redis Cache for WordPress for Faster Performance

Short answer: To set up Redis cache for WordPress, install Redis server on your hosting environment, then install and configure a Redis-backed object cache plugin like Redis Object Cache. This stores database queries in memory, reducing load times and improving Core Web Vitals.

Key takeaways

  • Redis caches database queries in memory for faster retrieval
  • Install Redis server on your server or use a managed Redis service
  • Use the Redis Object Cache plugin to connect WordPress to Redis
  • You can also use Redis for full-page caching with plugins like W3 Total Cache
  • Test performance with tools like Query Monitor to verify caching is working

You’ve heard that Redis can make your WordPress site blazing fast, but setting it up feels like a dark art. It’s not. Redis is an in-memory data store that takes the load off your database. Instead of querying MySQL for every page load, Redis stores the results in RAM. That means data retrieval happens in milliseconds instead of seconds. Let’s walk through the actual setup.

WordPress admin dashboard showing plugin settings for Redis object cache
The Redis Object Cache plugin makes connection simple. — Photo: pixelcreatures / Pixabay

What Is Redis Cache and Why Use It for WordPress?

Redis (Remote Dictionary Server) is an open-source, in-memory key-value store. When you enable Redis for WordPress, it caches database query results, objects, and sometimes full-page HTML. The first visitor triggers a database query; Redis stores that result. Subsequent visitors get the cached version from memory. No database hit. This reduces server load and speeds up page generation dramatically.

WordPress’s built-in object cache is ephemeral — it only lasts for a single page load. Redis makes it persistent across visits. That’s why you see big performance gains on dynamic sites, especially those with many logged-in users, WooCommerce stores, or membership sites.

Prerequisites: What You Need Before Installing Redis

Before you start, verify that your hosting environment supports Redis. Many managed WordPress hosts like Kinsta, WP Engine, and Cloudways offer Redis with a toggle. If you’re on a VPS or dedicated server (like DigitalOcean, Linode, or AWS), you can install Redis directly. Shared hosting rarely supports Redis — check with your provider.

You’ll also need SSH access to your server, or at least a control panel that lets you install Redis extensions. If you’re not comfortable with the command line, ask your host to install Redis for you.

Checking Your PHP Environment

Redis requires the PhpRedis extension installed on your server. You can verify this by logging into your WordPress admin and going to Tools > Site Health > Info and looking for ‘Redis’ under the Server section. If it’s not there, you or your host will need to install it.

If PhpRedis isn’t available, an alternative is the Predis library (a pure PHP implementation), but it’s slower. Always prefer PhpRedis for production.

Step-by-Step: Installing Redis on Your Server

Let’s assume you have a standard LEMP or LAMP stack on Ubuntu. SSH into your server and run the following commands:

sudo apt update
sudo apt install redis-server php8.x-redis

Replace 8.x with your PHP version. After installation, start the Redis service and enable it to start on boot:

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

Test that Redis is running with redis-cli ping. You should get a response of PONG. Then restart your web server (Nginx or Apache) to load the new PHP extension.

If you’re on a managed host, skip to the plugin step below.

Configuring Redis Object Cache in WordPress

Now it’s time to connect WordPress to Redis. The easiest way is with a dedicated plugin. I recommend the free Redis Object Cache plugin from the WordPress repository. Install and activate it, then go to Settings > Redis. Click the Enable Object Cache button. That’s it — your site is now using Redis to cache database queries.

You can verify by checking the plugin’s status. It should show ‘Connected’ with details about your Redis server. For advanced configuration, you can manually define Redis connection settings in your wp-config.php file, but the plugin handles this automatically in most cases.

Using Redis with W3 Total Cache for Full-Page Caching

If you want to cache full pages (not just database queries), you can use Redis as a backend for page caching too. W3 Total Cache supports this. In the plugin settings, go to Performance > General Settings, set the Page Cache method to ‘Redis’, and fill in the connection details (hostname, port, etc.). Save settings and purge the cache.

Full-page caching with Redis works well for anonymous traffic, but be careful with dynamic content. If you run WooCommerce or have logged-in users, you’ll need to cache page fragments manually or use a caching strategy that excludes certain pages.

Comparison: Redis vs. Other Caching Methods

To help you decide which caching layers to use, here’s a quick comparison:

MethodWhat It CachesSpeed ImpactBest For
File-based caching (e.g., WP Super Cache)HTML pagesFastSimple blogs with static content
Database query caching (Redis Object Cache)Database query resultsModerateDynamic sites with many queries
Redis full-page cachingHTML pages in memoryVery fastHigh-traffic sites with mostly static content
CDN cachingStatic assets (images, CSS, JS)FastReducing bandwidth and latency
Line graph showing website performance improvement after Redis cache setup on WordPress
Testing performance before and after Redis can show clear gains. — Photo: analogicus / Pixabay

Testing and Verifying Redis Cache Is Working

After setup, you want to confirm that Redis is actually caching. The Redis Object Cache plugin shows a ‘Cache Hit’ ratio on its settings page. A high hit ratio (above 80%) means it’s working. You can also use a query monitoring tool like Query Monitor to see database queries and check if they are being served from cache. Look for ‘Cache’ or ‘Redis’ in the output.

Another test: run a performance tool like PageSpeed Insights or GTmetrix before and after enabling Redis. You should see improvements in Time to First Byte (TTFB) and overall load time. However, remember that Redis primarily affects server response time; your Largest Contentful Paint (LCP) may not change much if your images and scripts are already optimized.

If you run into issues where Redis doesn’t seem to be caching or the cache flushes unexpectedly, check your Redis memory limits. By default, Redis uses up to 100 MB. If your site has a large object cache (e.g., many posts or options), you may need to increase it. Edit /etc/redis/redis.conf and set maxmemory 256mb or higher, then restart Redis.

Troubleshooting Common Redis Setup Issues

Here are a few pitfalls I’ve seen:

  • Redis not connecting: Make sure the PhpRedis extension is installed and your web server has been restarted. Check if Redis is listening on localhost (127.0.0.1) and port 6379 — the defaults.
  • Cache flushes constantly: Some plugins or themes flush the object cache unnecessarily. Use the Redis Object Cache plugin’s ‘Flush Cache’ button sparingly. If an external service like a membership plugin flushes cache too often, you may need to exclude certain cache groups.
  • Memory exhaustion: If Redis runs out of memory, it starts evicting keys. Set an appropriate maxmemory policy (like allkeys-lru) to keep the most popular cached data.

For deeper optimization, combine Redis with a good CDN. Check out our guide on Solving CDN Cache Issues on WordPress to ensure your static assets are also well-cached. And if you’re new to caching altogether, read our Beginner’s Guide to WordPress Caching first.

Wrapping Up: Your Next Steps

Redis is one of the most effective ways to speed up a WordPress site, especially if your site is database-heavy. Start by installing the Redis server and the Redis Object Cache plugin. Monitor your cache hit ratio. If your site is getting high traffic, consider full-page caching with Redis. Don’t forget to also leverage browser caching — we have a guide on How to Leverage Browser Caching in WordPress that pairs well with Redis. Take it step by step, test each change, and you’ll see real performance gains.

Frequently asked questions

Do I need a VPS to use Redis cache on WordPress?

Not necessarily. Many managed WordPress hosts offer Redis as an integrated feature you can enable from your dashboard. If you’re on shared hosting, Redis is usually not available because it requires server-level access. For a VPS or dedicated server, you can install Redis manually.

Will Redis cache conflict with other caching plugins?

Redis object cache works alongside page caching plugins like WP Super Cache or W3 Total Cache. They cache different layers. However, if you use full-page caching with Redis in W3 Total Cache, you should disable other page caching plugins to avoid conflicts.

How much memory should I allocate for Redis?

A good starting point is 128 MB. For large sites with many pages, users, or options, you might need 256 MB or more. Monitor your Redis memory usage via redis-cli INFO memory and adjust accordingly.

Can Redis improve Core Web Vitals scores?

Yes. Redis reduces server response time (TTFB), which can help your Largest Contentful Paint (LCP) if it’s server-related. However, LCP is also affected by image optimization and script loading, so Redis alone may not pass Core Web Vitals if other issues exist.

Is Redis safe for eCommerce sites like WooCommerce?

Yes, with caveats. Object caching works fine for WooCommerce. For full-page caching, you need to exclude cart, checkout, and my-account pages from the cache, or use fragment caching. Plugins like W3 Total Cache let you set up these exclusions.

Leave a Reply

Your email address will not be published. Required fields are marked *