From 4a0ebf0cb1c3a0b3a19955e5543c53ab8349cf32 Mon Sep 17 00:00:00 2001 From: spinline Date: Thu, 12 Feb 2026 22:31:53 +0300 Subject: [PATCH] fix: change WASM caching strategy to Network-First to resolve preload warnings --- frontend/sw.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/frontend/sw.js b/frontend/sw.js index 62a2eaf..4bc4ee3 100644 --- a/frontend/sw.js +++ b/frontend/sw.js @@ -88,7 +88,25 @@ self.addEventListener("fetch", (event) => { return; } - // Cache-first strategy for static assets (JS, CSS, Images) + // Special strategy for WASM and Main JS to prevent Preload warnings + if (url.pathname.endsWith(".wasm") || (url.pathname.endsWith(".js") && url.pathname.includes("frontend-"))) { + event.respondWith( + fetch(event.request) + .then((response) => { + const responseToCache = response.clone(); + caches.open(CACHE_NAME).then((cache) => { + cache.put(event.request, responseToCache); + }); + return response; + }) + .catch(() => { + return caches.match(event.request); + }), + ); + return; + } + + // Cache-first strategy for other static assets (CSS, Images, etc.) event.respondWith( caches.match(event.request).then((response) => { return (