Caching and CDNs

13 min read

Asking the database for the same answer again and again is slow and costly. A cache keeps popular answers close and ready. In this lesson you learn hits, misses, TTL, eviction and CDNs.

New words

Cache
A small, fast place that keeps copies of answers you need often.
Hit and miss
A hit finds the answer in the cache. A miss does not.
Hit rate
The share of requests that are hits, for example 90%.
TTL
Time to live: how long a saved answer is allowed to stay.
Eviction
Removing an old item from a full cache to make space.
CDN
Servers in many cities that keep copies of your content near users.

What you will learn

  1. The problem: the same question, again and again
  2. Hit, miss and hit rate
  3. TTL and stale data
  4. Eviction: when the cache is full
  5. Where caches live, and CDNs
  6. Try it: a small cache for a chai stall
  7. Trade-offs
  8. In a real system
  9. Interview tip
  10. Key takeaways

10 quiz questions at the end.

Start this lesson

The full lesson, with interactive demos and the quiz, opens after you sign in with Google. It is free.

All lessons · Back to the roadmap