Files
foodlinkk-command-center/cockpit/static/sw.js
T
Aissa 5d60d33db1 Platform bundle: marketing publish, IT ops, packaging, agents mesh.
Volledige Foodlinkk Command Center uitbreiding met social automatisering,
reclamefolder filters, Proxmox monitoring en documentatie.
2026-06-09 00:41:27 +00:00

47 lines
1.2 KiB
JavaScript

/* Foodlinkk PWA — light cache for shell */
const CACHE = 'foodlinkk-v1';
const ASSETS = [
'/',
'/static/css/palantir-theme.css',
'/static/css/pulse-theme.css',
'/static/css/mobile.css',
'/static/css/vertical-tabs.css',
'/static/js/cockpit.js',
'/static/js/live-pulse.js',
'/static/icons/app-icon.svg',
'/static/manifest.json',
];
self.addEventListener('install', (e) => {
e.waitUntil(
caches.open(CACHE).then((c) => c.addAll(ASSETS).catch(() => {}))
);
self.skipWaiting();
});
self.addEventListener('activate', (e) => {
e.waitUntil(
caches.keys().then((keys) =>
Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k)))
)
);
self.clients.claim();
});
self.addEventListener('fetch', (e) => {
if (e.request.method !== 'GET') return;
const url = new URL(e.request.url);
if (url.pathname.startsWith('/api/') || url.pathname.startsWith('/ws')) return;
e.respondWith(
fetch(e.request)
.then((r) => {
if (r.ok && url.pathname.startsWith('/static/')) {
const clone = r.clone();
caches.open(CACHE).then((c) => c.put(e.request, clone));
}
return r;
})
.catch(() => caches.match(e.request).then((m) => m || caches.match('/')))
);
});