Caching Strategies & CDN Design
Design caches that stay fast and correct: cache-aside, invalidation, stampedes, eviction, Redis, HTTP Cache-Control and ETags, and CDN keys and purging.
What you'll learn
- Decide what, where and how long to cache using hit ratio, working set and staleness requirements.
- Implement cache-aside, read-through, write-through and write-behind patterns with sensible TTLs.
- Invalidate caches reliably with deletes, versioned keys, tags and change data capture, and avoid race conditions.
- Prevent stampedes, avalanches, penetration and hot-key overload, and choose eviction policies.
- Write correct HTTP caching headers with Cache-Control, ETags, Vary and stale-while-revalidate.
- Design CDN caching with good cache keys, purging, micro-caching, edge security and safe handling of private data.
Syllabus
Why and Where to Cache
- What Caching Buys You
- Caching Layers from Browser to Database
- Hit Ratio, Effective Latency and the Working Set
Read and Write Patterns
- Cache-Aside (Lazy Loading)
- Read-Through, Write-Through, Write-Behind and Write-Around
- TTLs, Refresh-Ahead and Negative Caching
Invalidation and Consistency
Failure Modes Under Load
Eviction and Distributed Caches
HTTP Caching
- Cache-Control and Friends
- Validation: ETag, Last-Modified and Vary
- Stale-While-Revalidate, Stale-If-Error and Asset Fingerprinting