Inside the HTTP cache: a request’s whole journey
Memory cache, disk cache, service worker, CDN, origin. Five places a response can come from, and they disagree more often than you would like.
A request checks the memory cache first, then the service worker, then the disk cache, then whatever CDN sits in front of you, and only then your origin. Each layer has its own rules and its own idea of freshness.
- Memory cache.Per-tab, unversioned, and gone when the tab closes. Not something you can control.
- Service worker.Yours entirely, which is why a bad one is so hard to dislodge.
- Disk cache.Governed by your headers, shared across tabs, and the one people mean by “the cache”.
- CDN and origin.Shared across everyone, which is why Vary headers matter so much here.