delete old service worker caches

This commit is contained in:
Danny Coates 2018-11-16 12:31:36 -08:00
parent 32a55d00b2
commit 6fdc430c4f
No known key found for this signature in database
GPG Key ID: 4C442633C62E00CB
1 changed files with 8 additions and 2 deletions

View File

@ -80,9 +80,15 @@ async function decryptStream(id) {
}
async function precache() {
const oldCaches = await caches.keys();
for (const c of oldCaches) {
if (c !== version) {
await caches.delete(c);
}
}
const cache = await caches.open(version);
const x = assets.match(/.*\.(png|svg|jpg)$/);
await cache.addAll(x);
const images = assets.match(/.*\.(png|svg|jpg)$/);
await cache.addAll(images);
return self.skipWaiting();
}