mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Trying to update serviceworker and cache
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
//importScripts('/static/dist/lib/cache-polyfill.js');
|
//importScripts('/static/dist/lib/cache-polyfill.js');
|
||||||
|
|
||||||
var version = 'v0.5';
|
var version = 'v0.6';
|
||||||
var CACHE_FILES = [
|
var CACHE_FILES = [
|
||||||
'https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl=https://zoff.no/&choe=UTF-8&chld=L%7C1',
|
'https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl=https://zoff.no/&choe=UTF-8&chld=L%7C1',
|
||||||
'https://fonts.googleapis.com/icon?family=Material+Icons',
|
'https://fonts.googleapis.com/icon?family=Material+Icons',
|
||||||
@@ -52,11 +52,23 @@ self.addEventListener("activate", function(event) {
|
|||||||
*/
|
*/
|
||||||
//console.log('WORKER: activate event in progress.');
|
//console.log('WORKER: activate event in progress.');
|
||||||
|
|
||||||
|
var cacheWhitelist = version;
|
||||||
|
|
||||||
|
event.waitUntil(
|
||||||
|
caches.keys().then(function(keyList) {
|
||||||
|
return Promise.all(keyList.map(function(key) {
|
||||||
|
if (!key.startsWith(cacheWhitelist)) {
|
||||||
|
return caches.delete(key);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
})
|
||||||
|
);
|
||||||
|
/*
|
||||||
event.waitUntil(
|
event.waitUntil(
|
||||||
caches
|
caches
|
||||||
/* This method returns a promise which will resolve to an array of available
|
/* This method returns a promise which will resolve to an array of available
|
||||||
cache keys.
|
cache keys.
|
||||||
*/
|
|
||||||
.keys()
|
.keys()
|
||||||
.then(function (keys) {
|
.then(function (keys) {
|
||||||
// We return a promise that settles when all outdated caches are deleted.
|
// We return a promise that settles when all outdated caches are deleted.
|
||||||
@@ -69,7 +81,7 @@ self.addEventListener("activate", function(event) {
|
|||||||
.map(function (key) {
|
.map(function (key) {
|
||||||
/* Return a promise that's fulfilled
|
/* Return a promise that's fulfilled
|
||||||
when each outdated cache is deleted.
|
when each outdated cache is deleted.
|
||||||
*/
|
|
||||||
return caches.delete(key);
|
return caches.delete(key);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@@ -78,6 +90,7 @@ self.addEventListener("activate", function(event) {
|
|||||||
//console.log('WORKER: activate completed.');
|
//console.log('WORKER: activate completed.');
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
*/
|
||||||
});
|
});
|
||||||
|
|
||||||
self.addEventListener("fetch", function(event) {
|
self.addEventListener("fetch", function(event) {
|
||||||
|
|||||||
Reference in New Issue
Block a user