What is Redis and how does it dramatically speed up WordPress?
Redis is an in-memory key-value data store that caches WordPress database query results, transients, and sessions in RAM. Without caching, WordPress executes 20-50 MySQL queries per page load. With Redis Object Cache, subsequent loads serve from memory in under 1ms - reducing database load by 80-95%.
DETAILED EXPLANATION:
WordPress caching layers:
1. Full-page cache (LiteSpeed Cache, W3TC): Caches entire HTML as file. Fastest - bypasses PHP. Only for non-logged-in visitors.
2. Object cache (Redis): Caches WordPress DB query results, transient API calls. Speeds up dynamic page generation.
3. PHP OPcache: Caches compiled PHP bytecode. Separate from Redis.
What Redis stores for WordPress:
- Options table values (site_url, blogname etc.) - loaded on every request
- Post objects (title, content, meta) - cache for hours
- User data (for membership sites)
- WooCommerce product queries
- Widget output
Performance benchmark:
Before Redis: 47 DB queries per page load, 847ms generation time
After Redis: 3 DB queries (uncacheable), 89ms generation time
Speedup: 9.5x faster
WHEN TO USE:
- WordPress with 500+ daily visitors
- WooCommerce stores (heavy session + product query load)
- Membership sites with user-specific pages
- Any WordPress with many plugins (each adds DB queries)
STEP-BY-STEP - Redis setup on Connect Quest VPS:
1. Install Redis:
apt install redis-server php-redis
2. Configure /etc/redis/redis.conf:
maxmemory 256mb
maxmemory-policy allkeys-lru
bind 127.0.0.1
save ""
systemctl restart redis-server
redis-cli ping
Output: PONG
3. Install WordPress plugin:
WP Admin > Plugins > Add New > search "Redis Object Cache" by Till Kruss
Install and Activate > Settings > Redis > Enable Object Cache
4. Add to wp-config.php:
define( 'WP_REDIS_HOST', '127.0.0.1' );
define( 'WP_REDIS_PORT', 6379 );
define( 'WP_CACHE', true );
5. Check hit rate (target > 80%):
redis-cli info stats | grep -E "keyspace_hits|keyspace_misses"
Sample: hits=98432, misses=1247, hit rate=98.7% - excellent
REAL EXAMPLES:
WooCommerce benefit: Sessions stored in Redis instead of wp_options table.
Before: wp_options had 50,000+ autoloaded rows from sessions, causing slow ALL queries.
After: Sessions in Redis, wp_options stays under 500 rows.
FLOW:
Page request -> WordPress -> WP_Object_Cache::get("post_12")
-> Redis HIT: return cached object in <1ms
-> Redis MISS: MySQL query -> cache result -> return
KEY POINTS:
- Redis Object Cache plugin is free and the standard solution
- Set maxmemory with allkeys-lru eviction - never runs out of memory
- Disable Redis persistence (save "") for pure caching use case - faster
- Connect Quest VPS with NVMe SSD + Redis = fastest WordPress stack in India
COMMON MISTAKES:
- Installing Redis without maxmemory limit (can consume all available RAM)
- Not binding Redis to 127.0.0.1 (security risk if exposed publicly)
- Expecting Redis to cache pages for logged-in users (requires full-page cache)
QUICK FIX:
Redis connection failed in WP admin -> check: systemctl status redis-server
Verify WP_REDIS_HOST in wp-config.php matches Redis bind address (127.0.0.1)
DIFFICULTY: Intermediate
RELATED: WordPress Performance, VPS Hosting, MySQL Optimization, LiteSpeed
DETAILED EXPLANATION:
WordPress caching layers:
1. Full-page cache (LiteSpeed Cache, W3TC): Caches entire HTML as file. Fastest - bypasses PHP. Only for non-logged-in visitors.
2. Object cache (Redis): Caches WordPress DB query results, transient API calls. Speeds up dynamic page generation.
3. PHP OPcache: Caches compiled PHP bytecode. Separate from Redis.
What Redis stores for WordPress:
- Options table values (site_url, blogname etc.) - loaded on every request
- Post objects (title, content, meta) - cache for hours
- User data (for membership sites)
- WooCommerce product queries
- Widget output
Performance benchmark:
Before Redis: 47 DB queries per page load, 847ms generation time
After Redis: 3 DB queries (uncacheable), 89ms generation time
Speedup: 9.5x faster
WHEN TO USE:
- WordPress with 500+ daily visitors
- WooCommerce stores (heavy session + product query load)
- Membership sites with user-specific pages
- Any WordPress with many plugins (each adds DB queries)
STEP-BY-STEP - Redis setup on Connect Quest VPS:
1. Install Redis:
apt install redis-server php-redis
2. Configure /etc/redis/redis.conf:
maxmemory 256mb
maxmemory-policy allkeys-lru
bind 127.0.0.1
save ""
systemctl restart redis-server
redis-cli ping
Output: PONG
3. Install WordPress plugin:
WP Admin > Plugins > Add New > search "Redis Object Cache" by Till Kruss
Install and Activate > Settings > Redis > Enable Object Cache
4. Add to wp-config.php:
define( 'WP_REDIS_HOST', '127.0.0.1' );
define( 'WP_REDIS_PORT', 6379 );
define( 'WP_CACHE', true );
5. Check hit rate (target > 80%):
redis-cli info stats | grep -E "keyspace_hits|keyspace_misses"
Sample: hits=98432, misses=1247, hit rate=98.7% - excellent
REAL EXAMPLES:
WooCommerce benefit: Sessions stored in Redis instead of wp_options table.
Before: wp_options had 50,000+ autoloaded rows from sessions, causing slow ALL queries.
After: Sessions in Redis, wp_options stays under 500 rows.
FLOW:
Page request -> WordPress -> WP_Object_Cache::get("post_12")
-> Redis HIT: return cached object in <1ms
-> Redis MISS: MySQL query -> cache result -> return
KEY POINTS:
- Redis Object Cache plugin is free and the standard solution
- Set maxmemory with allkeys-lru eviction - never runs out of memory
- Disable Redis persistence (save "") for pure caching use case - faster
- Connect Quest VPS with NVMe SSD + Redis = fastest WordPress stack in India
COMMON MISTAKES:
- Installing Redis without maxmemory limit (can consume all available RAM)
- Not binding Redis to 127.0.0.1 (security risk if exposed publicly)
- Expecting Redis to cache pages for logged-in users (requires full-page cache)
QUICK FIX:
Redis connection failed in WP admin -> check: systemctl status redis-server
Verify WP_REDIS_HOST in wp-config.php matches Redis bind address (127.0.0.1)
DIFFICULTY: Intermediate
RELATED: WordPress Performance, VPS Hosting, MySQL Optimization, LiteSpeed