From 749be1fc6e8cb07741d0af420082b9982bb4ef2f Mon Sep 17 00:00:00 2001 From: LukeGus Date: Mon, 26 Jan 2026 23:06:34 -0600 Subject: [PATCH] fix: sw.js agressive caching --- public/sw.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/public/sw.js b/public/sw.js index 7dff4b23..462abdfb 100644 --- a/public/sw.js +++ b/public/sw.js @@ -60,21 +60,22 @@ self.addEventListener("fetch", (event) => { if (request.mode === "navigate") { event.respondWith( - fetch(request) - .then((response) => { - const responseClone = response.clone(); - caches.open(CACHE_NAME).then((cache) => { - cache.put(request, responseClone); - }); - return response; - }) - .catch(() => { - return caches.match("/index.html"); - }), + fetch(request).catch(() => { + return caches.match("/index.html"); + }), ); return; } + const isStaticAsset = STATIC_ASSETS.some((asset) => { + if (asset === "/") return url.pathname === "/"; + return url.pathname === asset || url.pathname.startsWith("/assets/"); + }); + + if (!isStaticAsset) { + return; + } + event.respondWith( caches.match(request).then((cachedResponse) => { if (cachedResponse) {