Spaces:
Running
Running
File size: 1,473 Bytes
19a0974 9d063d3 f3fd622 9d063d3 f3fd622 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | /* Vramwise offline cache. © 2026 CyberMax. All rights reserved. */
/* 16 Oct 2026: './' is not precached: the Hugging Face static host answers 404 for a folder URL, which made the whole install fail (no offline). Navigations fall back to index.html. */
var CACHE = "vramwise-v5";
var FILES = ["index.html", "style.css", "pro.js", "fit.css", "vramwise.js", "app.js", "manifest.webmanifest", "icon.svg", "icon-192.png", "icon-512.png"];
self.addEventListener("install", function (e) {
e.waitUntil(caches.open(CACHE).then(function (c) { return c.addAll(FILES); }).then(function () { return self.skipWaiting(); }));
});
self.addEventListener("activate", function (e) {
e.waitUntil(caches.keys().then(function (keys) {
return Promise.all(keys.filter(function (k) { return k !== CACHE; }).map(function (k) { return caches.delete(k); }));
}).then(function () { return self.clients.claim(); }));
});
self.addEventListener("fetch", function (e) {
if (e.request.method !== "GET" || new URL(e.request.url).origin !== location.origin) return;
// Network first so updates arrive quickly; cache as offline fallback.
e.respondWith(fetch(e.request).then(function (r) {
var copy = r.clone();
caches.open(CACHE).then(function (c) { c.put(e.request, copy); });
return r;
}).catch(function () { return caches.match(e.request, { ignoreSearch: true }).then(function (h) { return h || (e.request.mode === "navigate" ? caches.match("index.html") : h); }); }));
});
|