Using the CacheStorage API
The CacheStorage API is used to cache request/response object pairs where the request objects are the keys and the response objects are the values. It was designed to be used by service workers to provide offline functionality. A caches object is an instance of CacheStorage. It is a global object that is located in the window object.
We can use the following code to test if it is available on the browser:
const hasCaches = 'caches' in self;
A caches object is used to maintain a list of caches for a particular web app. Caches cannot be shared with other web apps and they are isolated from the browser's HTTP cache. They are entirely managed through the JavaScript that we write.
These are some of the methods of CacheStorage:
delete(cacheName): This method deletes the indicated cache and returnstrue. If the indicated cache is not found, it returnsfalse.has(cacheName): This method returnstrueif the indicated cache...