⏲️ Estimated reading time: 19 min
Table of Contents
Learn how to set up persistent object cache in WordPress using Redis or Memcached. This practical guide covers installation, server configuration, WordPress integration, security, verification, troubleshooting, and optimization to help reduce repeated database work and improve the performance of dynamic WordPress websites.
How to Set Up a Persistent Object Cache in WordPress
WordPress performance is not only about compressing images, using a CDN, or enabling page caching. Every time WordPress generates a dynamic page, it may request information from the database about posts, users, options, metadata, taxonomies, plugin settings, and many other elements. On larger or more dynamic websites, these database operations can become an important part of the total processing time.
A persistent object cache allows WordPress to keep reusable objects between PHP requests instead of discarding them when each request finishes. Redis and Memcached are two technologies commonly used for this purpose. In this tutorial, we will concentrate mainly on Redis because it integrates well with WordPress and is widely available on VPS and managed WordPress hosting.
What Is Persistent Object Cache in WordPress?
WordPress already includes an internal object caching system through the WP_Object_Cache class. WordPress Core, themes, and plugins can temporarily store information using functions such as wp_cache_get(), wp_cache_set(), and wp_cache_delete(). This prevents the same information from being unnecessarily generated or retrieved several times during a single request.
The important limitation is that WordPress’ standard object cache is normally non-persistent. When PHP finishes processing the request, those cached objects disappear. Redis or Memcached provides a persistent backend, allowing supported cached objects to remain available for subsequent requests.
How the Process Works
A simplified WordPress request without persistent object caching can look like this:
Visitor
↓
Web Server
↓
PHP
↓
WordPress
↓
Database
↓
Generated Page
With Redis enabled, WordPress gains another layer:
Visitor
↓
Web Server
↓
PHP
↓
WordPress
↓
Redis Object Cache
↓
Database when required
WordPress can first check Redis for previously cached information. When a valid object exists, WordPress can reuse it instead of repeating the original operation. The database is still essential, but Redis can reduce unnecessary repetitive work.
Persistent Object Cache vs Page Cache
Page caching and object caching are often confused, but they solve different performance problems. A page cache stores the final generated HTML page and can serve that copy without executing the complete WordPress application for every eligible visitor. Object caching works deeper inside WordPress by storing reusable application data while PHP and WordPress continue processing the request.
For many websites, the best configuration is not choosing one or the other. They can work together:
Browser Cache
↓
CDN / Edge Cache
↓
Page Cache
↓
PHP + WordPress
↓
Persistent Object Cache
↓
MySQL / MariaDB
A CDN or page cache is usually extremely effective for anonymous visitors reading public articles. Persistent object caching becomes especially useful for dynamic pages, logged-in users, WooCommerce, membership systems, wp-admin, REST API requests, and other situations where full-page caching cannot handle everything.
What Are the Benefits of Redis for WordPress?
The main advantage is reduced repetitive database work. Instead of repeatedly retrieving the same cacheable data from MySQL or MariaDB, WordPress can obtain it from Redis memory. This can reduce database pressure and improve response times, particularly on busy or database-intensive websites.
Redis can be especially useful for WooCommerce stores, membership sites, forums, LMS platforms, WordPress Multisite networks, high-traffic blogs, websites with large databases, and sites with many logged-in users. However, Redis does not automatically repair slow plugins, poor SQL queries, overloaded PHP workers, external API delays, or an underpowered server.
Does Every WordPress Website Need Redis?
Not necessarily. A small WordPress website containing a few pages, low traffic, and excellent full-page caching may experience only a small improvement. Adding Redis also introduces another service that must be maintained, monitored, secured, and updated.
On the other hand, Redis becomes much more valuable when the website frequently generates dynamic content or performs repeated database operations. The correct approach is to measure your website first and use persistent object caching when it solves a genuine performance requirement.
Step 1: Check Whether Your Hosting Supports Redis
Before installing anything, check your hosting control panel or contact your hosting provider. Search for options such as Redis, Object Cache, Persistent Object Cache, Memcached, or Application Cache. Many managed WordPress hosting environments already provide Redis and may have their own recommended method for activating it.
If your provider manages Redis for you, use its documented configuration instead of installing another Redis server manually. Managed environments can use custom ports, authentication, Unix sockets, containers, or private Redis servers, so generic instructions may not match your hosting configuration.
Step 2: Check WordPress Site Health
Open:
WordPress Dashboard
→ Tools
→ Site Health
WordPress Site Health can detect persistent object caching and may recommend enabling it when the website could benefit from the feature. If you see a recommendation similar to “You should use a persistent object cache”, it does not necessarily mean your website is broken. WordPress is recommending an additional performance optimization.
After Redis is correctly configured, Site Health should recognize that persistent object caching is enabled.
Step 3: Install Redis Object Cache for WordPress
One of the most popular solutions is the Redis Object Cache plugin. From your WordPress dashboard, navigate to:
Plugins
→ Add New Plugin
→ Search "Redis Object Cache"
→ Install Now
→ Activate
After activation, go to:
Settings
→ Redis
If Redis is already available on the server, the plugin may immediately detect it. If the connection fails, do not repeatedly enable and disable the plugin. First verify whether Redis actually exists on the server and whether PHP can communicate with it.
Step 4: Install Redis on Ubuntu or Debian
If you manage your own VPS and Redis is not installed, connect through SSH:
ssh your-user@your-server-ip
Update the package information and install Redis:
sudo apt update
sudo apt install redis-server -y
Enable the service and start it:
sudo systemctl enable redis-server
sudo systemctl start redis-server
Check its status:
sudo systemctl status redis-server
Finally, test Redis:
redis-cli ping
A successful response should be:
PONG
If you receive PONG, the Redis server is running and responding locally.
Step 5: Configure Redis Correctly
The Redis configuration file on many Ubuntu and Debian systems is located at:
/etc/redis/redis.conf
You can open it with:
sudo nano /etc/redis/redis.conf
Do not change settings simply because an older tutorial recommends them. Redis defaults and Linux packages change over time. Make only the adjustments required for your environment, then restart Redis:
sudo systemctl restart redis-server
Verify it again:
redis-cli ping
The response should remain:
PONG
Step 6: Secure Redis Before Connecting WordPress
Redis should generally not be exposed directly to the public internet just to provide WordPress object caching. On a typical single-server installation, WordPress and Redis can communicate locally through 127.0.0.1, a Unix socket, or another private interface.
The standard Redis port is:
6379
Do not simply open port 6379 in your firewall because WordPress cannot connect. If Redis runs on another server, use appropriate private networking, firewall restrictions, authentication, access controls, and encryption where required.
Step 7: Check PHP Redis Support
Redis itself is only one part of the configuration. PHP must also have a compatible Redis client available. You can check the command-line PHP environment with:
php -m | grep -i redis
If the Redis PHP extension is loaded, you should see:
redis
Remember that a server may have several PHP versions installed. Your command-line PHP version might differ from the version used by WordPress, so verify the PHP environment assigned to your domain through your hosting panel or PHP configuration.
Step 8: Connect WordPress to Redis
Return to:
WordPress Dashboard
→ Settings
→ Redis
For a standard local installation, Redis commonly uses:
Host: 127.0.0.1
Port: 6379
Once the plugin reports a successful connection, click Enable Object Cache. The plugin should install the required WordPress object-cache drop-in:
/wp-content/object-cache.php
This drop-in is important because WordPress detects it and uses the persistent object caching implementation instead of relying only on its standard request-level object cache.
Step 9: Configure Redis in wp-config.php
Simple installations may work without manually adding configuration constants. If your environment requires explicit Redis settings, you can define them in wp-config.php.
Example:
define( 'WP_REDIS_HOST', '127.0.0.1' );
define( 'WP_REDIS_PORT', 6379 );
When several WordPress installations share the same Redis environment, a unique prefix can help prevent cache key collisions:
define( 'WP_REDIS_PREFIX', 'example_com:' );
For another website, use something different:
define( 'WP_REDIS_PREFIX', 'another_site:' );
Always check the documentation of your Redis WordPress implementation before adding advanced constants.
Step 10: Verify the object-cache.php Drop-In
Open:
/wp-content/
and check for:
object-cache.php
Finding the file is a good sign, but it does not prove that Redis is working correctly. A complete verification should confirm that Redis is running, the WordPress plugin can connect, and the object-cache drop-in is active.
Step 11: Verify Redis with WP-CLI
If WP-CLI is available, you can check the Redis Object Cache status from the command line:
wp redis status
This is particularly useful when troubleshooting a website through SSH. It can help confirm the WordPress-side Redis configuration even when you cannot access wp-admin normally.
You can also verify Redis itself separately:
redis-cli ping
Remember the difference: redis-cli ping checks the Redis service, while WordPress-specific commands help determine whether WordPress is actually communicating with Redis.
Step 12: Verify Persistent Object Cache in Site Health
Go back to:
Tools
→ Site Health
Check the performance section again. WordPress should now detect the persistent object cache when the integration is working correctly.
You should also check:
Settings
→ Redis
A healthy setup should report that Redis is connected and that the object cache is enabled.
Step 13: Test Whether Redis Is Actually Being Used
Do not stop at a green status indicator. Browse several pages, open wp-admin, edit posts, and perform normal website operations. Then return to the Redis plugin’s diagnostics and examine the available statistics.
If you have server access, you can inspect Redis directly:
redis-cli INFO
For cache-related information:
redis-cli INFO stats
You can also inspect memory:
redis-cli INFO memory
These commands can help confirm that Redis is active and processing operations.
Step 14: Flush the Object Cache When Necessary
Sometimes you may need to clear Redis after changing themes, plugins, configurations, or troubleshooting stale data.
From WP-CLI:
wp cache flush
The Redis Object Cache plugin also provides controls for flushing its cache.
Do not create a habit of flushing Redis constantly. The entire point of persistent caching is to preserve useful objects. Immediately after a flush, WordPress has to rebuild those cache entries, so temporary database activity can increase.
Redis and WordPress Updates
You generally do not need to disable Redis before every normal WordPress update. Properly developed plugins and WordPress Core invalidate relevant cache objects when data changes.
However, after major migrations, database replacements, staging-to-production deployments, or complex troubleshooting, flushing the object cache may be appropriate. Always make a backup before performing major infrastructure changes.
See also: Top Famous Restaurants in Amsterdam You Must Visit
Redis and WooCommerce
WooCommerce contains significantly more dynamic behavior than a simple blog. Customer sessions, carts, accounts, orders, inventory operations, administrative screens, and database queries can create workloads that cannot always benefit from full-page caching.
Persistent object caching can therefore be valuable on WooCommerce websites. However, it must be configured correctly. Never assume that Redis allows you to aggressively cache shopping carts, checkout pages, or personalized HTML at the page-cache layer. Object caching and page caching remain different systems.
Redis and WordPress Multisite
Redis can also work very well with WordPress Multisite, but cache isolation deserves additional attention. Multiple sites can generate large numbers of cache keys, and incorrect prefixes or configuration can create difficult troubleshooting situations.
Before deploying Redis to a large Multisite network, test the setup on staging, monitor memory usage, and confirm compatibility with critical plugins.
Redis Memory Usage
Redis stores data primarily in memory, so it should not be allowed to consume resources without planning. On a VPS with limited RAM, Redis competes with PHP, MySQL or MariaDB, the operating system, web server, and other services.
Check memory usage with:
redis-cli INFO memory
You may see values such as:
used_memory
used_memory_human
used_memory_peak
maxmemory
If Redis continually consumes excessive memory, investigate your cache configuration instead of assuming that more caching is always better.
Should Redis Use a Maximum Memory Limit?
On production servers, defining an appropriate memory strategy can be sensible. The correct value depends on total server RAM, WordPress workload, database requirements, PHP workers, and other services.
Redis supports maxmemory and eviction policies, but there is no universal value that works for every WordPress website. A server with 2 GB of RAM requires a very different strategy from a server with 32 GB.
Never copy a random maxmemory value from another website without understanding your server.
Common Redis Connection Problems
Redis Server Is Not Running
Check:
sudo systemctl status redis-server
Start it if required:
sudo systemctl start redis-server
Redis Does Not Respond
Test:
redis-cli ping
You should receive:
PONG
PHP Redis Extension Is Missing
Check:
php -m | grep -i redis
If nothing appears, verify the PHP Redis extension or use another supported client according to your plugin and hosting environment.
Wrong Host or Port
The standard local configuration commonly uses:
127.0.0.1:6379
Your hosting provider may use something different, especially on managed hosting.
object-cache.php Is Missing
Check:
/wp-content/object-cache.php
If the Redis plugin is connected but the object cache is not enabled, activate it from the plugin settings.
Redis Works in SSH but Not WordPress
This often means the Redis server itself is fine, but PHP or WordPress cannot communicate with it. Check the PHP version used by the website, PHP Redis extension, Redis host, port, socket configuration, permissions, authentication, and WordPress plugin diagnostics.
What Is Memcached?
Memcached is another high-performance, memory-based caching system that can be used as a persistent object cache backend for WordPress. It is intentionally simple and can perform extremely well for straightforward key-value caching.
Redis offers additional data structures and features, which is one reason it has become a popular choice for modern WordPress environments. However, if your hosting provider already offers a professionally configured Memcached service, there may be no compelling reason to replace it simply because Redis is more commonly discussed.
Installing Memcached on Ubuntu or Debian
On a VPS, Memcached can be installed with:
sudo apt update
sudo apt install memcached -y
Enable and start it:
sudo systemctl enable memcached
sudo systemctl start memcached
Check the service:
sudo systemctl status memcached
You will also need a compatible PHP extension and WordPress object-cache implementation. Do not assume that installing the Linux package alone enables persistent object caching in WordPress.
Redis vs Memcached for WordPress
Both can provide fast in-memory object caching. Redis offers richer functionality, persistence options, extensive tooling, and broad WordPress ecosystem support. Memcached is simpler and highly effective for straightforward volatile caching.
For a new WordPress VPS where you control the infrastructure, Redis is often a practical choice. If your managed hosting environment already provides Memcached, use the platform-supported solution unless you have a specific technical reason to change it.

Persistent Object Cache Is Not a Replacement for Page Caching
This mistake is worth emphasizing.
Enabling Redis does not mean you should disable your page cache.
For a content website, serving a cached HTML page can avoid much more processing than running WordPress and retrieving a few objects from Redis.
A strong WordPress performance stack may include:
Cloudflare / CDN
+
Full-Page Cache
+
PHP OPcache
+
Redis Object Cache
+
Optimized Database
+
Optimized Images
These technologies complement each other.
Persistent Object Cache Is Not a Replacement for Database Optimization
Redis can hide some repetitive database work, but it cannot turn every inefficient query into an efficient one. Large autoloaded options, orphaned metadata, huge transients, poorly indexed custom tables, and inefficient plugin queries can still cause problems.
Treat Redis as a performance layer rather than a repair tool. If the database itself is unhealthy, investigate and optimize the underlying problem.
Should You Use a Redis WordPress Plugin and a Page Cache Plugin Together?
Yes, provided both tools are configured correctly.
For example, one plugin or server layer may manage full-page caching while Redis handles persistent object caching. They perform different tasks and can coexist.
What you should avoid is enabling several different plugins that all try to manage the same object-cache drop-in. WordPress can use only one active:
wp-content/object-cache.php
Choose one persistent object cache implementation and configure it correctly.
What Happens If Redis Goes Offline?
The exact behavior depends on your plugin, client, configuration, and hosting environment. A properly designed setup should avoid turning a temporary cache failure into a complete website outage whenever possible.
This is another reason to test Redis before using it on an important production site. After configuration, temporarily controlled failure testing on staging can reveal how your website behaves if Redis restarts or becomes unavailable.
Recommended Redis Setup Checklist
Before considering the configuration complete, verify:
- Redis is installed and running.
redis-cli pingreturnsPONG.- Redis is not unnecessarily exposed to the public internet.
- PHP has a compatible Redis client.
- WordPress can connect to Redis.
- The object cache is enabled.
wp-content/object-cache.phpexists.- WordPress Site Health detects persistent object caching.
- Different WordPress installations use appropriate cache isolation.
- Redis memory usage is monitored.
- Page caching remains correctly configured.
- Backups exist before major server changes.
Frequently Asked Questions
What is a persistent object cache in WordPress?
It stores reusable WordPress objects beyond a single PHP request. A backend such as Redis or Memcached allows WordPress to reuse cacheable information during later requests and potentially reduce repetitive database work.
Is Redis the same as a WordPress page cache?
No. Redis object caching stores reusable application data, while page caching normally stores generated HTML responses. They solve different performance problems and can be used together.
Does Redis make every WordPress website faster?
Not necessarily. Dynamic and database-intensive websites usually have more to gain. Small, mostly static sites with effective page caching may see a smaller difference.
Is Redis Object Cache free?
The Redis Object Cache WordPress plugin has a free version available through the official WordPress plugin directory. Commercial or managed Redis solutions may provide additional functionality.
Do I need VPS access to use Redis?
No. Many hosting companies provide Redis as part of their hosting infrastructure. Manual server installation is primarily necessary when you manage your own VPS or dedicated server.
What does PONG mean in Redis?
When you run:
redis-cli ping
and receive:
PONG
it confirms that the Redis server responded successfully to the client request.
Where is the WordPress object cache file?
A persistent object caching plugin commonly creates:
/wp-content/object-cache.php
WordPress recognizes this file as an object-cache drop-in.
Can Redis replace MySQL or MariaDB?
No. Redis is not replacing the WordPress database. Your posts, users, settings, comments, WooCommerce data, and other permanent information remain stored in the database.
Should I expose Redis port 6379 to the internet?
Generally, no. A standard WordPress server usually has no reason to expose Redis publicly. Use localhost, private networking, appropriate authentication, firewall restrictions, and other security measures according to your architecture.
Should I use Redis or Memcached?
Either can work. Redis is widely supported and offers additional functionality, while Memcached provides a simple and efficient memory caching system. If your host already manages one of them, using the officially supported option is usually the simplest approach.
A Faster WordPress Site Starts With the Right Cache Layers
Persistent object caching can be an excellent WordPress optimization, but its value comes from using it in the right environment. Redis can reduce repeated database work, improve some dynamic requests, and help busy WordPress websites handle application data more efficiently.
The best results come from combining Redis with good hosting, page caching, a CDN where appropriate, optimized PHP, a healthy database, efficient plugins, and regular performance monitoring. Install Redis because your website can benefit from persistent object caching, not simply because a performance test recommends another feature.
⚠️ Disclaimer and Source Hygiene
This tutorial is provided for educational and informational purposes. Server configurations differ between hosting providers, Linux distributions, PHP versions, WordPress installations, and Redis environments. Commands that work on one server may require adjustments on another.
Always create a complete backup before changing server services, PHP modules, WordPress configuration files, Redis settings, or production caching infrastructure. If you are not comfortable administering a Linux server, contact your hosting provider or a qualified system administrator. Technical information should also be verified against current WordPress, Redis, plugin, and hosting documentation before making production changes.
🔔 For more tutorials like this, consider subscribing to our blog.
📩 Do you have questions or suggestions? Leave a comment or contact us!
🏷️ Tags: WordPress object cache, persistent object cache, Redis WordPress, Redis Object Cache, WordPress performance, WordPress caching, Memcached WordPress, WordPress optimization, Redis server, WordPress Site Health
📢 Hashtags: #WordPress, #Redis, #WordPressCache, #ObjectCache, #WordPressPerformance, #WordPressOptimization, #WebPerformance, #WordPressTips, #Memcached, #WebHosting
Sources and References
WordPress Developer Resources
The official WordPress Developer documentation explains WP_Object_Cache, WordPress cache functions, persistent object cache behavior, and the Site Health checks used to detect object caching.
Official documentation:
developer.wordpress.org/reference/classes/wp_object_cache/
developer.wordpress.org/reference/classes/wp_site_health/get_test_persistent_object_cache/
Redis Documentation
For server installation, configuration, networking, security, memory management, and production Redis administration, consult the current Redis documentation rather than relying entirely on older server tutorials.
Official documentation:
redis.io/docs/
Redis Object Cache for WordPress
The Redis Object Cache plugin documentation provides current information about supported Redis clients, WordPress configuration, WP-CLI integration, connection parameters, and plugin-specific features.
Official plugin:
wordpress.org/plugins/redis-cache/
Secondary Sources and Testimonials
Hosting-specific Redis instructions can vary significantly. When using managed WordPress hosting, cPanel, Plesk, CloudPanel, or another server management platform, prioritize your hosting provider’s documentation because its Redis implementation may use custom sockets, ports, credentials, containers, or service management.
Real-world performance results also vary. A WooCommerce store with thousands of database operations can experience a very different result from a small cached blog. Benchmark your own website before and after enabling persistent object caching rather than relying solely on generic performance claims.