From a3a28d9aaca2f88efbc578df16221bfd7514eaef Mon Sep 17 00:00:00 2001 From: Jaifroid Date: Sun, 10 Jan 2021 12:51:59 +0000 Subject: [PATCH] Attempt to disable caching for cache.addAll Former-commit-id: bd5c457edf519e98901b409e19f881cee4e746a8 [formerly ae22d6aded2d1e661260cbe82e76c08b705c3eaa] [formerly 77d10f30bd1a908ee6252ea8ebf97eb7682f2e64] [formerly 84956687daf28c18399d4e305fbc6ef00098a93f [formerly 33b6d63ab58e5c471bc59c380673aec1273fc991 [formerly a8e38cba59ed092f91d751b4c3fcead3fbe0340a]]] Former-commit-id: 90decb464dd1bda04d7eced1e0090080b640da4a [formerly f2b7ee8db841785603666360761624b305ca0d03 [formerly 928b5346036a11b85582ec854c43a4127a94d1a7]] Former-commit-id: 496867c7bc8600b6d0d61574ca049dbd15ee9440 [formerly 7897c30572f944e7c9d5de8b7ca90f213d24c2bc] Former-commit-id: 9418cc40ba60caeca5472711914f2228d1c9e22e --- pwabuilder-sw.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pwabuilder-sw.js b/pwabuilder-sw.js index 45f34cae..b2257516 100644 --- a/pwabuilder-sw.js +++ b/pwabuilder-sw.js @@ -44,6 +44,7 @@ const precacheFiles = [ "www/css/bootstrap.min.css", "www/fonts/glyphicons-halflings-regular.woff2", "www/img/icons/kiwix-256.png", + "www/img/icons/kiwix-192.png", "www/img/icons/kiwix-32.png", "www/img/icons/kiwix-60.png", "www/img/icons/kiwix-blue-32.png", @@ -101,9 +102,21 @@ self.addEventListener("install", function (event) { console.log("[SW] Install Event processing"); self.skipWaiting(); var requests = precacheFiles.map(function(url) { - return new Request(url); + return new Request(url, { cache: 'no-cache' }); }); if (!excludedURLSchema.test(requests[0].url)) event.waitUntil( + // caches.open(CACHE).then(function (cache) { + // Promise.all( + // precacheFiles.map(fucntion (url) { + // // cache-bust using a random query string + // return fetch(`${url}?${Math.random()}`).then((response) => { + // // fail on 404, 500 etc + // if (!response.ok) throw Error('Not ok'); + // return cache.put(url, response); + // }); + // }) + // ); + // }) caches.open(CACHE).then(function (cache) { console.log("[SW] Caching pages during install"); return cache.addAll(requests).then().catch(function(err) {