From 695fd99b80854a9f3fca745139b0a38845df05c2 Mon Sep 17 00:00:00 2001 From: chris Date: Sat, 20 Jun 2026 23:29:06 -0400 Subject: [PATCH] Update sw.js --- sw.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/sw.js b/sw.js index 7b67327..e0a90d3 100644 --- a/sw.js +++ b/sw.js @@ -5,8 +5,8 @@ by: github.com/pvrzz =========================== */ -const CACHE = "toolscord-v1"; -const RUNTIME = "toolscord-runtime-v1"; +const CACHE = "toolscord-v2"; +const RUNTIME = "toolscord-runtime-v2"; const CORE = [ "./", "./index.html", @@ -39,6 +39,21 @@ self.addEventListener("fetch", (e) => { const url = new URL(req.url); if (url.hostname.endsWith("discord.com") || url.hostname.endsWith("discordapp.com")) return; + const isHTML = req.mode === "navigate" || (req.headers.get("accept") || "").includes("text/html"); + + if (isHTML) { + e.respondWith( + fetch(req) + .then((res) => { + const copy = res.clone(); + caches.open(CACHE).then((c) => c.put("./index.html", copy)).catch(() => {}); + return res; + }) + .catch(() => caches.match(req).then((r) => r || caches.match("./index.html"))) + ); + return; + } + e.respondWith( caches.match(req).then((cached) => { const network = fetch(req)