Fix PWA install hint dismiss after cached HTML/JS mismatch.

Restore button id, bind dismiss at document level, force hide inline, and fetch pwa.js/style.css network-first.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-20 15:37:30 +02:00
parent 6ba4cf447f
commit 0e9dbf1735
4 changed files with 45 additions and 17 deletions
+21 -1
View File
@@ -1,4 +1,4 @@
const CACHE = "if-viewer-static-v5";
const CACHE = "if-viewer-static-v6";
const ASSETS = [
"/static/style.css",
"/static/favicon.svg",
@@ -10,6 +10,11 @@ const ASSETS = [
"/static/locales/de.json",
];
const NETWORK_FIRST = new Set([
"/static/pwa.js",
"/static/style.css",
]);
self.addEventListener("install", (event) => {
event.waitUntil(
caches.open(CACHE)
@@ -33,6 +38,21 @@ self.addEventListener("fetch", (event) => {
if (url.pathname.includes("/api/")) return;
if (!url.pathname.startsWith("/static/")) return;
if (NETWORK_FIRST.has(url.pathname)) {
event.respondWith(
fetch(event.request)
.then((response) => {
if (response.ok) {
const copy = response.clone();
caches.open(CACHE).then((cache) => cache.put(event.request, copy));
}
return response;
})
.catch(() => caches.match(event.request))
);
return;
}
event.respondWith(
caches.match(event.request).then((cached) => cached || fetch(event.request))
);