Adding basic version for testing

This commit is contained in:
Dan 2026-02-21 18:24:08 +00:00
commit 139ad5958c
4 changed files with 936 additions and 0 deletions

30
sw.js Normal file
View file

@ -0,0 +1,30 @@
const CACHE = 'status-poster-v1';
const PRECACHE = ['.', 'index.html', 'manifest.json', 'sw.js', 'icon.svg'];
self.addEventListener('install', e => {
e.waitUntil(
caches.open(CACHE)
.then(c => c.addAll(PRECACHE))
.then(() => self.skipWaiting())
);
});
self.addEventListener('activate', e => {
e.waitUntil(
caches.keys()
.then(keys => Promise.all(
keys.filter(k => k !== CACHE).map(k => caches.delete(k))
))
.then(() => self.clients.claim())
);
});
self.addEventListener('fetch', e => {
// Never intercept API calls — always go to network
if (e.request.url.includes('api.omg.lol')) return;
e.respondWith(
caches.match(e.request)
.then(cached => cached || fetch(e.request))
);
});