bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths

Loading lesson path

Learn/System Design/Building Blocks
System Design•Building Blocks

Caching & CDNs

Caching trades freshness for latency. A cache only helps when the read pattern is hot, the freshness tolerance is known, and the invalidation path is explicit.

Key ideas

  • Cache-aside: app reads cache, on miss loads the DB and backfills the cache.
  • Write-through / write-back: writes go through the cache; stronger freshness, more complexity.
  • A CDN caches static and cacheable responses at the edge, close to users.

Compare

StrategyTradeoff
Cache-aside + TTLSimple, eventual freshness; stale window equals the TTL
Write-throughFresh reads, slower writes
No cacheAlways fresh, full DB load

Warning

A cache without an invalidation plan just moves the bug closer to your users.

Previous

Load Balancing & Stateless Services

Next

Sharding & Replication