Designs multi-layer caching — CDN, server, database — with invalidation and stampede prevention.
Click to play with sound.
---
name: Caching Strategy
description: Design correct multi-layer caching.
---
# Caching Strategy
Add caching where it helps, and keep it correct under invalidation and load.
## Layers
1. Browser/CDN: cache static and cacheable responses near the user.
2. Application: in-memory or Redis for computed results and hot objects.
3. Database: query cache, materialized views, read replicas.
Cache as close to the consumer as correctness allows.
## Patterns
- Cache-aside (lazy): on miss, load from source, store, return. Most common.
- Read-through / write-through: cache sits inline with the store.
- Write-behind: buffer writes, flush async (risk of loss).
```text
get(key):… install to load the full skillSign in to rate and review this skill.
No reviews yet. Be the first to review this skill.