From 191c21afaad67da06ffc9484ef888ba3e794d842 Mon Sep 17 00:00:00 2001 From: -k Date: Thu, 17 Oct 2024 22:23:38 -0700 Subject: [PATCH] perf(pwa): store updated content only --- static/sw.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/static/sw.js b/static/sw.js index 44f57ae..d9a1c0a 100644 --- a/static/sw.js +++ b/static/sw.js @@ -58,7 +58,9 @@ onfetch = (event) => { return cache.match(event.request) .then((cachedResponse) => { const fetchedResponse = fetch(event.request).then((networkResponse) => { - if (networkResponse.status < 400) { + if ((networkResponse.status < 400) + && (cachedResponse.headers.get("Last-Modified") + !== networkResponse.headers.get("Last-Modified"))) { console.log("Caching the response to", event.request.url); cache.put(event.request, networkResponse.clone()); } else {