mirror of
https://github.com/kiwix/kiwix-js-pwa.git
synced 2025-09-08 19:57:46 -04:00
Add version control
Former-commit-id: 52c81eda62352d2011c5070e74166fd4f46e5c4d [formerly 81465b6e11d06b016de9cc8592e16d450af79b4f] [formerly 50d9a37b713073ce278d268765ef404547741997] [formerly 9e5278b3f895074f1cd4ca15a4f5776dc4923a16 [formerly a46a21957a3d70ee13561574f1a889eaf5e64f6b [formerly c90d29659e8ecd284aedcfd32f09d13337513076]]] Former-commit-id: 7fa95c977c9ed0c9bca0919ca851271dabef047f [formerly 90ad67002100e44494d86370fcef11147f09b659 [formerly 033b07f4d5dfa365f446ea1d160ab9b962307afd]] Former-commit-id: 79705a0f938775406f1564c24ffdba6dec794f44 [formerly 8ce730c38a9c3de059625364b01a19e3b081434f] Former-commit-id: 0473cced3af55866d975fb2370f340116acede44
This commit is contained in:
parent
6bc8ea4437
commit
dcbb694a4f
@ -102,7 +102,7 @@ self.addEventListener("install", function (event) {
|
||||
console.log("[SW] Install Event processing");
|
||||
self.skipWaiting();
|
||||
var requests = precacheFiles.map(function(url) {
|
||||
return new Request(url, { cache: 'no-cache' });
|
||||
return new Request(url + '?v' + appVersion, { cache: 'no-cache' });
|
||||
});
|
||||
if (!excludedURLSchema.test(requests[0].url)) event.waitUntil(
|
||||
// caches.open(CACHE).then(function (cache) {
|
||||
@ -264,9 +264,12 @@ function intercept(event) {
|
||||
}, [messageChannel.port2]);
|
||||
});
|
||||
} else {
|
||||
// It's not a ZIM URL
|
||||
return fetch(event.request).then(function (response) {
|
||||
// If request was success, add or update it in the cache
|
||||
if (!excludedURLSchema.test(event.request.url)) event.waitUntil(updateCache(event.request, response.clone()));
|
||||
if (!excludedURLSchema.test(event.request.url) && !/\.zim\w{0,2}$/i.test(event.request.url)) {
|
||||
event.waitUntil(updateCache(event.request, response.clone()));
|
||||
}
|
||||
return response;
|
||||
}).catch(function (error) {
|
||||
console.log("[SW] Network request failed and no cache.", error);
|
||||
|
Loading…
x
Reference in New Issue
Block a user