System Design
Intermediate

Caching Strategies

Use caches to reduce latency and load without corrupting correctness.

30 min
3 sections
cache
redis
cdn
1
2
3

01. Choose the right cache boundary

Section 1 of 3

Cache at the CDN for public static data, in the client for user experience, in the service for expensive computations, and near the database for hot reads. Each boundary has different invalidation and privacy risks.

text
Cache decision matrix:

Public product image: CDN cache, long TTL, versioned URL
User profile page: service cache, short TTL, user-scoped key
Inventory count: avoid stale cache or use bounded staleness
Feature flags: local memory cache with streaming invalidation
Search results: cache query result for popular filters
Back to Course