Caching and CDNs
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
- The problem: the same question, again and again
- Hit, miss and hit rate
- TTL and stale data
- Eviction: when the cache is full
- Where caches live, and CDNs
- Try it: a small cache for a chai stall
- Trade-offs
- In a real system
- Interview tip
- Key takeaways
10 quiz questions at the end.
The full lesson, with interactive demos and the quiz, opens after you sign in with Google. It is free.