Redis Persistent Object Cache
Redis object caching stores expensive query results and computed objects in memory so WordPress does not repeat the same work on every request. It matters most for dynamic paths (logged-in sessions, cart/checkout, admin, search) where page cache is bypassed.
Object Cache vs Page Cache
| Type | Scope | Works For | Limitation |
|---|---|---|---|
| Page Cache (LSCache, CDN) | Full HTML response | Anonymous users, static content | Logged-in users bypass it |
| Object Cache (Redis) | Database query results, objects, metadata | Logged-in users, WooCommerce carts, LMS sessions | Needs Redis server + proper config |
How Redis Improves WordPress Performance
| Action | Without Redis | With Redis | Benefit |
|---|---|---|---|
| Product Page Load | 50+ queries run every request | Queries cached in memory | TTFB 100-300ms |
| Checkout Page | Queries hit DB directly | Cart/session data served from Redis | Stable checkout under load |
| Dashboard Access | DB hit for options/transients | Options pulled from Redis | Faster wp-admin |
Implementation Steps
-
Install Redis on Ubuntu VPS:
install-redis-ubuntu.shsudo apt updatesudo apt install -y redis-server -
Enable Redis Persistence (RDB/AOF):
Edit
/etc/redis/redis.conf:redis.confsave 900 1save 300 10appendonly yesRestart Redis:
restart-redis.shsudo systemctl restart redis -
Install WordPress Plugin:
- Use Redis Object Cache plugin or LiteSpeeds built-in Redis connector.
-
Enable Object Cache:
wp-redis-enable.shwp redis enable -
Verify Connection:
wp-redis-status.shwp redis status
Static vs Dynamic Strategy
| Site Type | Redis Usage | Why |
|---|---|---|
| Static (Blogs) | Optional, minor gains | Mostly cached via page/CDN layers |
| Dynamic (WooCommerce, LMS, Membership) | Required, persistent cache ON | Handles cart, account, logged-in sessions efficiently |
Best Practices
- Run Redis on the same server unless scaling with high concurrency (then consider managed Redis).
- Set a memory limit for Redis to avoid over-usage.
- Use persistent mode (RDB + AOF) for reliability.
- Flush Redis carefully; avoid doing it during peak hours.
- Monitor Redis hit/miss ratio weekly.
Verification Steps
Check Redis plugin status:
wp-redis-status.sh
wp redis status
Expected Output:
wp-redis-status-output.txt
Status: Connected
Client: PhpRedis
Cache Hits: 12000
Cache Misses: 3000
Check via Redis CLI:
redis-info-stats.sh
redis-cli info stats | grep keyspace
Expected Output:
redis-info-stats-output.txt
keyspace_hits:15000
keyspace_misses:2500
Quick Lab
- Install Redis on your VPS.
- Enable persistence in
/etc/redis/redis.conf. - Install the Redis Object Cache plugin.
- Run
wp redis enableto activate object cache. - Load your site, then check
wp redis status. - Compare TTFB before and after enabling Redis.
Cheat Sheet (Redis Persistent Cache)
| Task | Command |
|---|---|
| Install Redis | sudo apt install redis-server -y |
| Restart Redis | sudo systemctl restart redis |
| Enable Object Cache | wp redis enable |
| Flush Redis | wp redis flush |
| Check Status | wp redis status |
| Monitor Hits/Misses | redis-cli info stats |
Expected Impact
With a properly configured persistent object cache, expect lower database load, steadier dynamic TTFB, and fewer performance collapses under concurrency.