Caching responses
We have been able to store content, including data and site assets using web storage and IndexedDB for several years. Using either medium requires a library or custom logic to manage site assets, which is why the service worker specification includes a specialized Cache API.
The Cache interface provides a managed storage mechanism for Request/Response object pairs. These objects are also referred to as network addressable resources, but you can think about them as just files or API responses.
The Cache API has a natural advantage over IndexedDB and localStorage because it is designed to abstract, persisting these assets by the Request and Response objects. This means that you can reference the assets using more than just ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access