October 2017
Intermediate to advanced
302 pages
7h 27m
English
We need to go through each key and call caches.delete() if it doesn't match our CACHE_NAME. Since we may have multiple caches to delete, and multiple calls to caches.delete(), which returns a Promise in itself, we'll map over keyList and return a set of Promises using Promise.all().
Here's what it looks like:
self.addEventListener('activate', event => { event.waitUntil( caches.keys().then(keyList => { Promise.all(keyList.map(key => { })); }) );});
Delete any cache whose key doesn’t match CACHE_NAME.
A simple if statement, and a call to caches.delete(), and we're done:
self.addEventListener('activate', event => { event.waitUntil( caches.keys().then(keyList => { Promise.all( keyList.map(key => { if (key !== CACHE_NAME) { return ...Read now
Unlock full access