Posts

Showing posts from June, 2020

Working with the JavaScript Cache API

The  Cache API  is a system for storing and retrieving network requests and their corresponding responses. These might be regular requests and responses created in the course of running your application, or they could be created solely for the purpose of storing data for later use. The Cache API was created to enable service workers to cache network requests so that they can provide fast responses, regardless of network speed or availablity. However, the API can also be used as a general storage mechanism. Where is it available?  # The Cache API is available in  all modern browsers . It is exposed via the global  caches  property, so you can test for the presence of the API with a simple feature detection: const cacheAvailable = 'caches' in self ; The Cache API can be accessed from a window, iframe, worker, or service worker. What can be stored  # The caches only store pairs of  Request  and  Response  objects, representing HTTP requests and responses, respectively. However