From 1ed46b8ade610cd0dfc69683798a3b3b4cfca526 Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Thu, 1 Dec 2022 08:09:22 +0000 Subject: [PATCH] implement fix for strange first load cache behavior --- source/sw.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/sw.js b/source/sw.js index 2f9f21a..7410aae 100644 --- a/source/sw.js +++ b/source/sw.js @@ -34,12 +34,15 @@ self.addEventListener("install", async () => { }); self.addEventListener("fetch", (event) => { + console.log(`fetching: ${event.request.url}`); event.respondWith(caches.open(CACHE_NAME).then((cache) => { return fetch(event.request).then((fetchedResponse) => { cache.put(event.request, fetchedResponse.clone()); + console.log(typeof(fetchedResponse)); return fetchedResponse; }).catch(() => { - return cache.match(event.request); + console.log(cache.match(event.request, {ignoreVary: true})); + return cache.match(event.request, {ignoreVary: true}); }); })); });