Summary
Caching stores reusable data closer to where it is needed. A CDN is a geographically distributed caching and delivery network, usually for web assets and edge responses.
Interview Points
- Caches can exist in browser, app, database, memory, or edge.
- CDNs reduce latency and origin load by serving content near users.
- Cache invalidation and freshness are the hard parts.
- CDNs are strongest for static assets and cacheable HTTP responses.
- Dynamic data may use short TTL, revalidation, or surrogate keys.
2-3 Minute Interview Script
“Caching is a general technique: store data so future reads are faster or cheaper. A CDN is a specific infrastructure layer that caches and serves content from edge locations close to users.
I would use browser caching and CDN caching for static assets, images, scripts, and public content. For application data, I might use Redis or an in-process cache depending on latency and consistency needs.
The hard problem is not putting data in a cache; it is deciding freshness and invalidation. TTLs, cache keys, revalidation, and purge mechanisms need to match product correctness.
Interview answer: caching reduces repeated work; CDN reduces network distance and origin load.”
Follow-Ups
- What should not be cached?
- How do you invalidate CDN content?