Skip to main content

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

TypeScopeWorks ForLimitation
Page Cache (LSCache, CDN)Full HTML responseAnonymous users, static contentLogged-in users bypass it
Object Cache (Redis)Database query results, objects, metadataLogged-in users, WooCommerce carts, LMS sessionsNeeds Redis server + proper config

How Redis Improves WordPress Performance

ActionWithout RedisWith RedisBenefit
Product Page Load50+ queries run every requestQueries cached in memoryTTFB 100-300ms
Checkout PageQueries hit DB directlyCart/session data served from RedisStable checkout under load
Dashboard AccessDB hit for options/transientsOptions pulled from RedisFaster wp-admin

Implementation Steps

  1. Install Redis on Ubuntu VPS:

    install-redis-ubuntu.sh
    sudo apt update
    sudo apt install -y redis-server
  2. Enable Redis Persistence (RDB/AOF):

    Edit /etc/redis/redis.conf:

    redis.conf
    save 900 1
    save 300 10
    appendonly yes

    Restart Redis:

    restart-redis.sh
    sudo systemctl restart redis
  3. Install WordPress Plugin:

    • Use Redis Object Cache plugin or LiteSpeeds built-in Redis connector.
  4. Enable Object Cache:

    wp-redis-enable.sh
    wp redis enable
  5. Verify Connection:

    wp-redis-status.sh
    wp redis status

Static vs Dynamic Strategy

Site TypeRedis UsageWhy
Static (Blogs)Optional, minor gainsMostly cached via page/CDN layers
Dynamic (WooCommerce, LMS, Membership)Required, persistent cache ONHandles cart, account, logged-in sessions efficiently

Best Practices

  1. Run Redis on the same server unless scaling with high concurrency (then consider managed Redis).
  2. Set a memory limit for Redis to avoid over-usage.
  3. Use persistent mode (RDB + AOF) for reliability.
  4. Flush Redis carefully; avoid doing it during peak hours.
  5. 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

  1. Install Redis on your VPS.
  2. Enable persistence in /etc/redis/redis.conf.
  3. Install the Redis Object Cache plugin.
  4. Run wp redis enable to activate object cache.
  5. Load your site, then check wp redis status.
  6. Compare TTFB before and after enabling Redis.

Cheat Sheet (Redis Persistent Cache)

TaskCommand
Install Redissudo apt install redis-server -y
Restart Redissudo systemctl restart redis
Enable Object Cachewp redis enable
Flush Rediswp redis flush
Check Statuswp redis status
Monitor Hits/Missesredis-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.

What's Next