cache-first strategy
A caching strategy that answers from the cache when possible and only goes to the network, then caches the result, on a miss.
In more detail
It gives instant, offline-proof loads and suits hashed static files that never change. For changing data it would serve stale content forever.
Related terms
- network-first strategy — A caching strategy that tries the network first for fresh data and falls back to the cached copy only when the request fails.
- stale-while-revalidate — A caching strategy that answers immediately from the cache, even if out of date, while fetching a fresh copy in the background for next time.
- Cache Storage API — A browser storage API that saves pairs of Request and Response objects in named caches, usually managed by a service worker.
- hashed file name — A file name that includes a hash of the file's contents, such as app.3f9a1c.js, so any change produces a new name.
Taught in
- Cache Storage API: Offline Strategies And Cache-First Patterns — Frontend Architecture & Web Platform