fix: sw.js agressive caching

This commit is contained in:
LukeGus
2026-01-26 23:06:34 -06:00
parent 98b760ce64
commit 749be1fc6e
+12 -11
View File
@@ -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) {