StarDomain
Hosting & Performance

Redis Caching: Supercharge Your Website Performance

Redis can make your database queries 100x faster. Learn what Redis is, how it works, and how to use it for caching.

E
Editorial Team
March 18, 2026
6 min read1 views

What is Redis?

Redis is an in-memory data store used primarily as a cache. Instead of querying the database for every request, Redis stores frequently accessed data in RAM — which is orders of magnitude faster.

Speed Comparison

OperationMySQLRedis
Simple query1-10ms0.1ms
Complex query50-500ms0.1ms
Session lookup5-20ms0.1ms

Common Use Cases

1. Database Query Cache

Cache expensive database results:

Request → Check Redis → Hit? Return cached → Miss? Query DB → Store in Redis → Return

2. Session Storage

Store user sessions in Redis instead of files/database:

  • Faster session reads
  • Shared across multiple servers
  • Automatic expiration

3. Full-Page Cache

Cache entire rendered pages:

  • Bypass PHP/application entirely
  • Sub-millisecond response times
  • Ideal for content that doesn't change often

4. Rate Limiting

Track request counts efficiently:

Key: rate:192.168.1.1
Value: 47 (request count)
TTL: 60 seconds

Redis with WordPress

Object Cache

WordPress makes hundreds of database queries per page. Redis object cache reduces this dramatically.

Setup:

  1. Install Redis on your server
  2. Install the "Redis Object Cache" plugin
  3. Add to wp-config.php:
php
define('WP_REDIS_HOST', '127.0.0.1');
define('WP_REDIS_PORT', 6379);

Expected Results

  • Database queries: 200+ → 5-10 per page
  • Page generation: 500ms → 50ms
  • Server load: 80% reduction

Redis Commands Cheat Sheet

bash
# Connect
redis-cli

# Set/Get values
SET mykey "Hello"
GET mykey

# Set with expiration (60 seconds)
SETEX mykey 60 "Hello"

# Check TTL
TTL mykey

# Delete key
DEL mykey

# List all keys (use with caution in production)
KEYS pattern*

# Server info
INFO memory
INFO stats

# Flush all data
FLUSHALL

Best Practices

  1. Set TTL on all keys — prevent memory overflow
  2. Use key prefixeswp:cache:, session:, rate:
  3. Monitor memory — set maxmemory policy
  4. Use Redis Sentinel for high availability
  5. Secure with password and bind to localhost

Conclusion

Redis is the single most impactful performance upgrade for dynamic websites. If your site makes database queries on every request, Redis caching can reduce response times by 90%+ with minimal setup effort.

Share this article
E
Written by

Editorial Team

Our editorial team shares expert knowledge and practical insights to help you succeed online with hosting, domains, and web technology.