July 2018
Intermediate to advanced
354 pages
8h 51m
English
If you want to retrieve an asset and immediately cache the response, the add and addAll methods manage this process. The add method is equivalent to the following code:
const precache_urls = [...]
caches.open(preCacheName).then(function (cache) {
return cache.addAll(precache_urls);
})
Both the add and addAll methods have a single parameter: a request object. Like the match method, you can also supply a valid URL and the method will convert it into a request object.
Both methods return a promise, but do not resolve a value. As long as there were no exceptions making and caching the requests, you can use the resolution to continue the application workflow. If there was an exception, you can catch and handle it appropriately. ...
Read now
Unlock full access