AI Hints
Home›System Design Tutorial›Redis and Cache Layers
System Design · Lesson 62 of 120

Layers of Caching

From browser to database.

⏱ 2 min read▶ Video at 1:13:58🎓 Free
Watch this lesson in the System Design courseWatch on YouTube ↗Full System Design course

Caching doesn't happen in just one place. A single page view can pass through five different caches, from the user's own browser all the way down to the database.

Layers of Caching
From the video: Layers of Caching
  • Not just one place
  • Five layers
  • Browser to database

The caching layers

Starting closest to the user. The browser cache keeps files on the user's device. The CDN caches at edge servers nearby. The application can cache in its own memory. A shared cache, like Redis, serves all app servers. And the database has its own cache of recently used data.

  1. Database cacherecent pages of data
  2. Shared cacheRedis, all servers
  3. App memoryinside each server
  4. CDNedge servers
  5. Browseron the user's device

Using the layers well

The closer the cache is to the user, the faster it is, but the harder it is to clear. Browser caches can't be cleared by you at all, so files get version numbers in their names. Shared caches are easy to clear. Choose the layer based on how fresh the data must be.

keyvalue
Closerfaster
Closerharder to clear
Browser filesversion the names
Shared cacheeasy to clear

Summary

Caches live in the browser, the CDN, the app, a shared store, and the database. Closer is faster, but harder to clear. Next, a quiz on caching.

Key takeaways
  • Browser, CDN
  • App, Redis
  • Database cache
Next up: Caching Quiz — test yourself