Stage 3 · Build
Performance & Caching at Scale
Redis Cache Invalidation
Design TTLs, versioned keys, write-through updates, pub/sub invalidation, and stale data safeguards.
Invalidation Strategies
Cache invalidation is hard because it must happen consistently across multiple application instances. If one instance invalidates a cache entry but others do not, stale data persists until TTL expiry.
| Strategy | Consistency | Complexity |
|---|---|---|
| TTL expiry | Eventually consistent | Low |
| Delete on write | Mostly consistent | Low |
| Pub/Sub broadcast | Consistent | Medium |
| Write-through | Consistent | Medium |
Versioned Keys
Pub/Sub Invalidation
Stale Data Safeguards
Cache Warming
Monitoring Hit Rates
Always invalidate the cache before updating the database. If you update the database first, another request may read stale data and repopulate the cache before invalidation happens.
Mark this lesson complete to store local progress and unlock a cleaner resume path the next time you visit.