Category: Performance
Redis object cache can make a WordPress site feel faster by reducing repeated database work. It is especially useful for WooCommerce stores, membership sites, LMS platforms, busy blogs, logged-in user dashboards, multilingual websites, large admin panels, and plugin-heavy WordPress setups.
WordPress already has an object cache system, but by default it is usually non-persistent. That means cached data normally lasts only for the current page request. When you add Redis as a persistent object cache backend, WordPress can reuse cached database query results and expensive objects across multiple requests.
This guide explains how to set up Redis object cache for WordPress step by step, including server installation, PHP extension setup, plugin configuration, wp-config.php constants, WP-CLI commands, testing, troubleshooting, and rollback.
TL;DR: Redis Object Cache Setup
To set up Redis object cache for WordPress, install Redis on the server, keep it private on 127.0.0.1 or a Unix socket, install the PHP Redis extension if needed, install the Redis Object Cache plugin, add Redis connection constants to wp-config.php, enable the object cache from Settings → Redis or with wp redis enable, then verify that wp-content/object-cache.php exists and the plugin status says connected. Always test on staging first for WooCommerce, membership, LMS, or high-traffic sites.
What Is Redis Object Cache in WordPress?
Redis is an in-memory data store often used for caching. In WordPress, Redis can be used as a persistent object cache backend. Instead of repeatedly asking the database for the same data, WordPress can store certain objects in Redis and retrieve them faster on later requests.
Object cache can store things like:
- Database query results.
- Post objects.
- User objects.
- Options and settings.
- Transients.
- Term and taxonomy data.
- Metadata lookups.
- Plugin-generated cached data.
Official reference: WordPress Object Cache.
Object Cache vs Page Cache: Know the Difference
Redis object cache is not the same as page cache. Both can improve performance, but they work at different layers.
| Cache Type | What It Stores | Best For |
|---|---|---|
| Page cache | Full HTML page output | Logged-out visitors, blogs, landing pages, business sites |
| Object cache | Database objects and computed data | Dynamic sites, WooCommerce, logged-in users, admin speed |
| Browser cache | Static assets in visitor browser | Images, CSS, JavaScript, fonts |
| CDN cache | Static assets or cached HTML at edge locations | Global visitors and static delivery |
A normal blog may benefit more from page cache and image optimization first. A WooCommerce or membership site often benefits from object cache because many pages are dynamic and cannot be fully page-cached.
When Should You Use Redis Object Cache?
Redis is useful when WordPress repeatedly performs database-heavy work. It is not required for every small website, but it can be a major performance improvement for dynamic or busy sites.
Redis object cache is useful for:
- WooCommerce stores.
- Membership websites.
- LMS websites.
- BuddyPress or community sites.
- High-traffic blogs.
- Large WordPress admin dashboards.
- Multisite networks.
- Sites with many logged-in users.
- Sites with heavy custom queries.
- Sites with slow database response time.
- Plugin-heavy WordPress builds.
Redis may not help much if:
- Your site is small and already fully page-cached.
- Your database is already fast and traffic is low.
- Your main issue is huge images or JavaScript bloat.
- Your hosting does not allow Redis.
- Your site is misconfigured at the PHP/server level.
- You cannot monitor or troubleshoot cache issues.
Before You Start: Requirements
Redis object cache needs both server-level and WordPress-level setup. Installing only a WordPress plugin is not enough if Redis is not running on the server.
You need:
- Server or hosting support for Redis.
- SSH/root access, or a host that enables Redis for you.
- PHP Redis extension or a supported Redis client such as Predis.
- A WordPress object cache plugin.
- Permission to edit
wp-config.php. - Ability to test and disable object cache if something breaks.
Best practice before setup:
- Take a database backup.
- Take a file backup.
- Test on staging first if the site is business-critical.
- Check current PHP version.
- Check whether another object cache drop-in already exists.
Check current WordPress environment:
wp --info
wp core version
php -v
Check whether an object cache drop-in already exists:
ls -la wp-content/object-cache.php
If wp-content/object-cache.php already exists, your site may already use another object cache system. Do not overwrite it blindly.
Step 1: Back Up WordPress First
Redis setup is usually safe, but object cache misconfiguration can cause login problems, stale data, connection errors, or admin issues. Back up before changing server cache behavior.
Database backup with WP-CLI:
wp db export before-redis-cache.sql
Files backup with SSH:
tar -czf wordpress-files-before-redis.tar.gz /path/to/wordpress
Minimum files to copy before editing:
wp-config.phpwp-content/object-cache.phpif it already exists- Any existing cache plugin configuration
FyrePress tool: Use the FyrePress wp-config.php Builder when preparing configuration constants for review.
Step 2: Install Redis on Ubuntu or Debian
If your host already provides Redis, skip to the WordPress plugin setup. If you manage your own VPS, install Redis at the server level first.
Simple Ubuntu/Debian package install:
sudo apt update
sudo apt install redis-server -y
Enable and start Redis:
sudo systemctl enable redis-server
sudo systemctl start redis-server
Check Redis status:
sudo systemctl status redis-server
Test Redis:
redis-cli ping
Expected response:
PONG
Official reference: Install Redis on Linux.
Step 3: Install Redis on AlmaLinux, Rocky Linux, or CentOS-style Servers
Commands can vary by distribution and repository setup, but the common process is to install Redis, enable it, start it, and test with redis-cli ping.
Install Redis:
sudo dnf install redis -y
Enable and start Redis:
sudo systemctl enable redis
sudo systemctl start redis
Test Redis:
redis-cli ping
Expected response:
PONG
If the package is not available, enable the correct repository for your operating system or use your host’s preferred Redis installation method.
Step 4: Secure Redis Before Connecting WordPress
Redis should not be publicly exposed to the internet. For most single-server WordPress setups, Redis should listen locally only.
Open Redis config:
sudo nano /etc/redis/redis.conf
Recommended local binding:
bind 127.0.0.1 ::1
protected-mode yes
port 6379
Restart Redis after changes:
sudo systemctl restart redis-server
On some systems, the service name is redis instead of redis-server:
sudo systemctl restart redis
Security checklist:
- Do not expose Redis port
6379publicly. - Bind Redis to
127.0.0.1for local WordPress setups. - Use firewall rules to block external access.
- Use authentication or sockets for more controlled setups.
- Do not share one Redis database across unrelated sites without prefixes or separate databases.
- Use separate Redis databases or prefixes for each WordPress site.
UFW firewall example:
sudo ufw deny 6379
If Redis runs on a separate private server, use private networking, firewall rules, authentication, and TLS where appropriate. Do not send Redis traffic over the public internet without proper protection.
Step 5: Install the PHP Redis Extension
WordPress needs a PHP Redis client to talk to Redis. The common choice is the PhpRedis extension. Some plugins can also use Predis, but PhpRedis is usually preferred on production servers when available.
Ubuntu/Debian:
sudo apt install php-redis -y
Restart PHP-FPM and web server:
sudo systemctl restart php8.3-fpm
sudo systemctl restart nginx
Replace php8.3-fpm with your installed PHP-FPM version, such as php8.2-fpm, php8.1-fpm, or your hosting-specific PHP service.
Apache example:
sudo systemctl restart apache2
Check whether Redis extension is loaded:
php -m | grep redis
Expected output:
redis
Alternative check:
php -i | grep -i redis
If no Redis PHP extension appears, ask your host to install or enable PhpRedis for your PHP version.
Step 6: Install the Redis Object Cache Plugin
The easiest WordPress-level setup is the Redis Object Cache plugin from WordPress.org. It creates the Redis object cache drop-in and gives you a settings screen to check the connection.
Install from WordPress dashboard:
- Go to Plugins → Add New.
- Search for Redis Object Cache.
- Install the plugin.
- Activate the plugin.
- Go to Settings → Redis.
- Click Enable Object Cache.
Install with WP-CLI:
wp plugin install redis-cache --activate
Enable object cache with WP-CLI:
wp redis enable
Check Redis status:
wp redis status
Official plugin reference: Redis Object Cache plugin.
Step 7: Add Redis Settings to wp-config.php
The plugin can often connect automatically to 127.0.0.1:6379. For cleaner setup, especially on VPS or multisite environments, define Redis constants in wp-config.php.
Add these above the final stop-editing comment:
define( 'WP_REDIS_HOST', '127.0.0.1' );
define( 'WP_REDIS_PORT', 6379 );
define( 'WP_REDIS_DATABASE', 0 );
define( 'WP_REDIS_PREFIX', 'example_com_' );
define( 'WP_REDIS_TIMEOUT', 1 );
define( 'WP_REDIS_READ_TIMEOUT', 1 );
Correct placement:
define( 'WP_REDIS_HOST', '127.0.0.1' );
define( 'WP_REDIS_PORT', 6379 );
define( 'WP_REDIS_DATABASE', 0 );
define( 'WP_REDIS_PREFIX', 'example_com_' );
define( 'WP_REDIS_TIMEOUT', 1 );
define( 'WP_REDIS_READ_TIMEOUT', 1 );
/* That's all, stop editing! Happy publishing. */
Why prefix matters:
A unique prefix helps avoid cache key collisions when multiple WordPress sites use the same Redis instance or database.
Good prefix examples:
define( 'WP_REDIS_PREFIX', 'example_com_' );
define( 'WP_REDIS_PREFIX', 'client1_production_' );
define( 'WP_REDIS_PREFIX', 'store_live_' );
Bad prefix examples:
define( 'WP_REDIS_PREFIX', 'wordpress_' );
define( 'WP_REDIS_PREFIX', 'site_' );
define( 'WP_REDIS_PREFIX', 'wp_' );
Generic prefixes are more likely to collide on servers with multiple WordPress installations.
Step 8: Configure Redis With a Unix Socket Optional
On single-server setups, a Unix socket can be faster and more secure than TCP because Redis does not need to listen on a network port for local WordPress communication.
Redis config example:
port 0
unixsocket /var/run/redis/redis-server.sock
unixsocketperm 770
Restart Redis:
sudo systemctl restart redis-server
wp-config.php socket setup:
define( 'WP_REDIS_SCHEME', 'unix' );
define( 'WP_REDIS_PATH', '/var/run/redis/redis-server.sock' );
define( 'WP_REDIS_DATABASE', 0 );
define( 'WP_REDIS_PREFIX', 'example_com_' );
Important socket notes:
- The PHP user must have permission to access the socket.
- The Redis socket path can vary by operating system.
- Managed hosts may not allow socket-level changes.
- Incorrect permissions can cause Redis connection failure.
For beginners, TCP on 127.0.0.1:6379 is usually easier. For tuned VPS setups, Unix sockets are worth considering.
Step 9: Verify the Object Cache Drop-In
WordPress uses a drop-in file to replace the default non-persistent object cache with Redis-backed object caching.
Check the drop-in file:
ls -la wp-content/object-cache.php
If Redis Object Cache is enabled correctly, this file should exist:
wp-content/object-cache.php
Check with WP-CLI:
wp redis status
Check from WordPress dashboard:
- Go to Settings → Redis.
- Check that status shows connected.
- Check response time and diagnostic information.
- Confirm object cache is enabled.
Check Redis keys from terminal:
redis-cli keys '*'
On production servers, avoid using KEYS * on very large Redis databases because it can be expensive. For small test setups, it is fine for quick confirmation.
Safer production scan:
redis-cli --scan | head
Step 10: Test Site Behavior After Enabling Redis
After enabling Redis, test the website carefully. Do not assume a green status means every site workflow is safe.
Test these pages:
- Homepage.
- Important blog posts and pages.
- WordPress admin dashboard.
- Post editor.
- Media library.
- Search page.
- Forms.
- Logged-in user pages.
- WooCommerce product pages.
- Cart and checkout if used.
- Account page if used.
- Membership or LMS dashboards if used.
Check logs:
- PHP error log.
- WordPress debug log.
- Redis server log.
- Web server error log.
- WooCommerce logs if relevant.
FyrePress tool: If Redis creates PHP warnings, connection errors, 500 errors, or slow request logs, review the log excerpt with the FyrePress Server Log Analyzer.
Step 11: Flush Redis Object Cache Safely
Sometimes you need to flush object cache after migrations, plugin updates, database imports, search-replace operations, or strange stale-data behavior.
Flush using WP-CLI:
wp cache flush
Flush using Redis Object Cache command:
wp redis flush
Flush Redis database from terminal:
redis-cli FLUSHDB
Warning:
FLUSHDB clears the selected Redis database. If multiple sites share the same Redis database, this can clear cache for all of them. Use separate databases or unique prefixes where possible.
Flush all Redis databases only if you fully understand the server:
redis-cli FLUSHALL
Do not use FLUSHALL on shared or multi-tenant servers unless you are absolutely sure it is safe.
Step 12: Measure the Performance Impact
Redis object cache should reduce repeated database work, but you should measure before and after rather than guessing.
What to check:
- Database query count.
- Database query time.
- Admin dashboard speed.
- WooCommerce order screen speed.
- Checkout performance.
- Logged-in page response time.
- Server CPU and database load.
- Redis memory usage.
- Cache hit ratio if available.
Useful tools:
- Redis Object Cache plugin diagnostics.
- Query Monitor plugin.
- Server monitoring.
- Slow query logs.
- Hosting performance tools.
- Browser DevTools.
Check Redis memory:
redis-cli INFO memory
Check Redis stats:
redis-cli INFO stats
Recommended Redis Settings for WordPress
The best Redis settings depend on your server size and traffic, but these are practical starting points for many WordPress VPS setups.
Basic wp-config.php settings:
define( 'WP_REDIS_HOST', '127.0.0.1' );
define( 'WP_REDIS_PORT', 6379 );
define( 'WP_REDIS_DATABASE', 0 );
define( 'WP_REDIS_PREFIX', 'example_com_' );
define( 'WP_REDIS_TIMEOUT', 1 );
define( 'WP_REDIS_READ_TIMEOUT', 1 );
Redis memory limit example:
Open Redis config:
sudo nano /etc/redis/redis.conf
Add or adjust:
maxmemory 256mb
maxmemory-policy allkeys-lru
Restart Redis:
sudo systemctl restart redis-server
What this means:
maxmemorylimits how much RAM Redis can use.allkeys-lruallows Redis to evict older keys when memory fills.- The right memory value depends on server RAM and site size.
Do not give Redis too much memory on a small VPS. PHP, database, web server, and operating system also need RAM.
Redis Object Cache for WooCommerce
WooCommerce can benefit from Redis because it performs many dynamic database operations. But WooCommerce also needs careful testing because carts, sessions, orders, checkout, and payment flows are sensitive.
WooCommerce testing checklist:
- Product pages load correctly.
- Product variations work.
- Cart updates correctly.
- Checkout works.
- Payment gateway callbacks work.
- Order status changes correctly.
- Stock updates correctly.
- Customer account page works.
- Admin order screen loads faster or normally.
- No stale cart or account data appears.
WooCommerce caution:
Never test Redis only on the homepage of a WooCommerce store. Test cart, checkout, account, and order-management workflows before calling the setup complete.
Redis Object Cache for Multisite
WordPress multisite needs special care because multiple sites may share the same Redis instance.
Multisite checklist:
- Use a unique Redis prefix for the network.
- Confirm object cache works across subsites.
- Test network admin.
- Test subsite admin pages.
- Check domain-mapped subsites.
- Avoid cache key collisions between networks.
- Use separate Redis databases for separate networks where possible.
Example multisite prefix:
define( 'WP_REDIS_PREFIX', 'network_example_com_' );
On multisite, flushing object cache can affect the whole network. Plan carefully before using global flush commands.
Common Redis Object Cache Errors and Fixes
Error: Status not connected
Redis is not reachable from WordPress.
Check Redis is running:
sudo systemctl status redis-server
redis-cli ping
Check wp-config.php:
define( 'WP_REDIS_HOST', '127.0.0.1' );
define( 'WP_REDIS_PORT', 6379 );
Error: Connection refused
Redis may not be running, may be listening on a different host/port, or firewall/socket permissions may be wrong.
Check listening port:
sudo ss -tulpn | grep 6379
Error: PHP Redis extension missing
Install or enable the PHP Redis extension.
sudo apt install php-redis -y
sudo systemctl restart php8.3-fpm
Error: object-cache.php already exists
Another cache plugin may already be using an object cache drop-in.
Check existing file:
ls -la wp-content/object-cache.php
Disable current cache first if needed:
mv wp-content/object-cache.php wp-content/object-cache.php.backup
Do this only after confirming what created the existing drop-in.
Error: Site works but admin shows stale data
Flush object cache and check whether multiple sites share a Redis database or prefix.
wp cache flush
wp redis flush
Error: Redis uses too much memory
Set a memory limit and eviction policy in Redis config.
maxmemory 256mb
maxmemory-policy allkeys-lru
How to Disable Redis Object Cache Safely
If Redis causes problems, disable the object cache cleanly instead of deleting random files.
Disable with WP-CLI:
wp redis disable
Deactivate plugin:
wp plugin deactivate redis-cache
Remove object cache drop-in manually if needed:
rm wp-content/object-cache.php
Remove Redis constants from wp-config.php:
define( 'WP_REDIS_HOST', '127.0.0.1' );
define( 'WP_REDIS_PORT', 6379 );
define( 'WP_REDIS_DATABASE', 0 );
define( 'WP_REDIS_PREFIX', 'example_com_' );
After disabling Redis object cache, clear page cache and test the site again.
Do You Need define('WP_CACHE', true) for Redis?
No, not for Redis object cache specifically. The WP_CACHE constant is commonly related to page caching drop-ins such as advanced-cache.php. Redis object cache depends on the object cache drop-in file:
wp-content/object-cache.php
Do not add define( 'WP_CACHE', true ); only because you are enabling Redis object cache. Add it only when your page caching plugin or host requires it.
Best Setup by Hosting Type
Shared hosting
Ask your host whether Redis is available. Many shared hosts do not allow custom Redis services. If supported, they may provide the host, port, socket, or plugin setup.
Managed WordPress hosting
Check whether the host already provides Redis or object cache. Some managed hosts use their own object cache plugin or drop-in, so do not overwrite it without checking.
VPS hosting
Install Redis locally, secure it on 127.0.0.1 or a Unix socket, install PhpRedis, configure wp-config.php, then enable the Redis Object Cache plugin.
WooCommerce hosting
Use Redis, but test cart, checkout, account pages, payment gateways, order status changes, and admin order screens carefully.
Multisite hosting
Use unique prefixes or separate Redis databases. Test network admin and subsites before enabling Redis across the whole network.
Redis Object Cache Setup Checklist
- Back up WordPress files and database.
- Check whether object cache is already active.
- Install Redis server.
- Secure Redis on local host or socket.
- Install PHP Redis extension.
- Restart PHP-FPM and web server.
- Install Redis Object Cache plugin.
- Add
WP_REDIS_*constants towp-config.php. - Enable object cache from dashboard or WP-CLI.
- Confirm
wp-content/object-cache.phpexists. - Run
wp redis status. - Test frontend and admin pages.
- Test WooCommerce or membership workflows if used.
- Monitor Redis memory and logs.
- Keep rollback commands ready.
Common Mistakes to Avoid
- Installing the plugin without installing Redis server.
- Exposing Redis port
6379publicly. - Using the same Redis database and prefix for multiple sites.
- Overwriting an existing
object-cache.phpdrop-in blindly. - Testing only the homepage after enabling Redis.
- Using
FLUSHALLon a shared Redis server. - Giving Redis too much memory on a small VPS.
- Ignoring WooCommerce cart and checkout testing.
- Assuming Redis fixes image, CSS, JavaScript, or CDN problems.
- Not keeping a rollback plan.
Final Recommendation
Redis object cache is one of the best upgrades for dynamic WordPress sites, especially WooCommerce, membership, LMS, multisite, and logged-in user platforms. It reduces repeated database work and can make admin and dynamic pages feel faster.
The safest setup is to install Redis locally, keep it private, use PhpRedis, configure a unique prefix in wp-config.php, enable the Redis Object Cache plugin, and test the site carefully. For stores and membership sites, test checkout, account, order, and logged-in workflows before considering the setup complete.
Redis is not a replacement for page cache, CDN, image optimization, clean plugins, or good hosting. It is one layer in a proper WordPress performance stack.
Frequently Asked Questions
What is Redis object cache in WordPress?
Redis object cache is a persistent caching layer that stores WordPress objects, database query results, options, transients, and other computed data in Redis so WordPress can reuse them across requests.
Does WordPress need Redis object cache?
Not every WordPress site needs Redis. It is most useful for WooCommerce, membership sites, LMS platforms, multisite networks, high-traffic blogs, logged-in user sites, and database-heavy WordPress builds.
Is Redis object cache the same as page cache?
No. Page cache stores full HTML page output, while object cache stores database objects and computed data. Many WordPress sites benefit from using both together.
How do I know Redis object cache is working?
Check Settings → Redis in WordPress, run wp redis status, and confirm that wp-content/object-cache.php exists. You can also check Redis keys with redis-cli --scan.
Do I need WP_CACHE true for Redis object cache?
No. Redis object cache uses the wp-content/object-cache.php drop-in. The WP_CACHE constant is usually related to page cache systems, not Redis object cache by itself.
Can Redis break WordPress?
Redis can cause issues if misconfigured, unavailable, exposed publicly, shared incorrectly between sites, or used with stale cache data. Most problems can be fixed by disabling the object cache drop-in and clearing cache.
How do I clear Redis cache in WordPress?
Use wp cache flush, wp redis flush, or the Redis plugin dashboard. Avoid FLUSHALL unless you are sure the Redis server is not shared with other sites or services.
Should Redis be public?
No. Redis should not be exposed publicly. For most WordPress setups, it should listen on 127.0.0.1 or a Unix socket and be protected by firewall rules.
Is Redis good for WooCommerce?
Yes, Redis can help WooCommerce because stores are dynamic and database-heavy. However, you must test cart, checkout, account pages, payment gateways, and order management after enabling it.
How do I disable Redis object cache?
Run wp redis disable, deactivate the Redis Object Cache plugin, remove wp-content/object-cache.php if needed, and remove Redis constants from wp-config.php.