2026-07-19 15:35:18 +02:00
|
|
|
/* ── IPFS Portal Service Worker ──
|
|
|
|
|
* Minimal offline cache for static assets.
|
|
|
|
|
* Auto-generated — do not edit manually.
|
2026-06-28 18:31:05 +02:00
|
|
|
*/
|
2026-07-19 15:35:18 +02:00
|
|
|
const CACHE = 'ipfs-portal-v1';
|
|
|
|
|
const PRECACHE = ['/', '/manifest.json', '/favicon.svg'];
|
2026-06-28 18:31:05 +02:00
|
|
|
|
2026-07-19 15:35:18 +02:00
|
|
|
self.addEventListener('install', (e) => {
|
|
|
|
|
e.waitUntil(
|
|
|
|
|
caches.open(CACHE).then((c) => c.addAll(PRECACHE)).then(() => self.skipWaiting()),
|
2026-06-28 18:31:05 +02:00
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
2026-07-19 15:35:18 +02:00
|
|
|
self.addEventListener('activate', (e) => {
|
|
|
|
|
e.waitUntil(
|
|
|
|
|
caches.keys().then((keys) => Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k)))),
|
2026-06-28 18:31:05 +02:00
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
2026-07-19 15:35:18 +02:00
|
|
|
self.addEventListener('fetch', (e) => {
|
|
|
|
|
if (e.request.method !== 'GET') return;
|
|
|
|
|
e.respondWith(
|
|
|
|
|
caches.match(e.request).then((cached) => cached || fetch(e.request).then((res) => {
|
|
|
|
|
if (res.ok && res.url.startsWith(self.location.origin)) {
|
|
|
|
|
const clone = res.clone();
|
|
|
|
|
caches.open(CACHE).then((c) => c.put(e.request, clone));
|
|
|
|
|
}
|
|
|
|
|
return res;
|
|
|
|
|
})),
|
|
|
|
|
);
|
2026-06-28 18:31:05 +02:00
|
|
|
});
|