JavaScript › Browser Storage & Web APIs
What is the Cache API and how does it relate to Service Workers?
AdvancedAnswer
The Cache API lets you store Request/Response pairs programmatically, most commonly from within a Service Worker, to serve assets offline or speed up repeat loads. Unlike browser HTTP caching, you fully control what's cached and for how long.
caches.open('v1').then(cache => {
cache.addAll(['/', '/styles.css', '/app.js']);
});Real-world example Precaching an app's shell so it still loads (with a fallback UI) when the user is offline.