Cache and CacheStorage Flashcards
What is CacheStorage?
The CacheStorage interface represents the storage for Cache objects. It provides a master directory of all the named caches that a ServiceWorker, other type of worker or window scope can access (you don’t have to use it with service workers, even though that is the spec that defines it) and maintains a mapping of string names to corresponding Cache objects.
What does CacheStorage expose?
CacheStorage.open() and CacheStorage.match().
Describe: CacheStorage.open().
Returns a Promise that resolves to the Cache object matching the cacheName (a new cache is created if it doesn’t exist.).
What method is used to obtain a Cached instance?
CacheStorage.open().
What method is used to check if a given Request is a key in any of the Cache objects that the CacheStorage object tracks?
CacheStorage.match().
Describe: CacheStorage.has().
Returns a Promise that resolves to true if a Cache object matching the cacheName exists.
Describe: CacheStorage.match().
Checks if a given Request is a key in any of the Cache objects that the CacheStorage object tracks and returns a Promise that resolves to that match.
Describe: CacheStorage.delete().
Finds the Cache object matching the cacheName, and if found, deletes the Cache object and returns a Promise that resolves to true. If no Cache object is found, it returns false.
Describe: CacheStorage.keys().
Returns a Promise that will resolve with an array containing strings corresponding to all of the named Cache objects tracked by the CacheStorage. Use this method to iterate over a list of all the Cache objects.