Redis Cache Returning Stale Data - Cache Not Invalidating
Users see old data from Redis cache even after updates. Cache doesn't invalidate when data changes.
Data appears correct in database but cached version is stale.
Error Messages You Might See
Common Causes
- Cache TTL too long - data expires slowly
- No cache invalidation on update/delete operations
- Cache key structure doesn't match query conditions
- Updating database but forgetting to delete cache
- Multiple cache keys for same data causing duplicates
How to Fix It
Invalidate cache on writes: after update, delete cache key: redis.del('user:123')
Use pattern deletion: redis.del('user:*') to clear all user cache
Set reasonable TTL: 5-60 minutes depending on data freshness needs
Implement cache versioning: 'user:v1:123' changes if schema changes
Use Redis pub/sub to invalidate cache across multiple servers
Real developers can help you.
You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.
Get HelpFrequently Asked Questions
What's a good cache TTL?
User data: 1 hour. Product data: 24 hours. Real-time data: 5 minutes. Balance freshness and performance
Should I invalidate on every update?
Yes, delete cache key on write. Otherwise users see outdated data
How do I handle cache across multiple servers?
Use Redis pub/sub: publish invalidation message. All servers receive and delete cache