Skip to content

Commit

Permalink
Cache more stuff? clear old caches?
Browse files Browse the repository at this point in the history
  • Loading branch information
sz3 committed Jun 13, 2021
1 parent e20a3cd commit 8fa1509
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions web/sw.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@

var _cacheName = 'cimbar-js-v0.5.8';
var _cacheName = 'cimbar-js-v0.5.8.aaa';
var _cacheFiles = [
'/',
'/index.html',
'/cimbar_js.js',
'/cimbar_js.wasm',
'/main.js'
'/favicon.ico',
'/main.js',
'/pwa.json'
];

// fetch files
Expand All @@ -28,12 +31,11 @@ self.addEventListener('fetch', function(e) {

// clean old caches
self.addEventListener('activate', function(e) {
e.waitUntil(caches.keys().then(function(keyList) {
Promise.all(keyList.map(function(key) {
if (key === _cacheName) {
return;
}
caches.delete(key);
}));
})());
e.waitUntil(function() {
caches.keys().then(function(names) {
for (var i in names)
if (names[i] != _cacheName)
caches.delete(names[i]);
});
});
});

0 comments on commit 8fa1509

Please sign in to comment.