idiouf commited on
Commit
8193e4e
·
verified ·
1 Parent(s): 81c41ca

Upload 185 files

Browse files
Files changed (1) hide show
  1. sw.js +4 -5
sw.js CHANGED
@@ -1,5 +1,4 @@
1
- const CACHE='ul-module-v48';
2
- const CORE=['./index.html','./','./logo-ul.png','./manifest.webmanifest','./app-192.png','./app-512.png',...Array.from({length:7},(_,i)=>'./police-0'+(i+1)+'.ttf')];
3
- self.addEventListener('install',e=>{e.waitUntil(caches.open(CACHE).then(c=>c.addAll(CORE)));self.skipWaiting()});
4
- self.addEventListener('activate',e=>e.waitUntil(caches.keys().then(ks=>Promise.all(ks.filter(k=>k.startsWith('ul-module-')&&k!==CACHE).map(k=>caches.delete(k)))).then(()=>self.clients.claim())));
5
- self.addEventListener('fetch',e=>{if(e.request.method!=='GET'||new URL(e.request.url).origin!==location.origin||/\.(zip|pptx)$/.test(new URL(e.request.url).pathname))return;e.respondWith(fetch(e.request).then(res=>{if(res.ok){const copy=res.clone();caches.open(CACHE).then(c=>c.put(e.request,copy))}return res}).catch(()=>caches.match(e.request).then(r=>r||(e.request.mode==='navigate'?caches.match('./index.html'):Response.error()))))});
 
1
+ // Protected edition: never cache course content or authenticated responses.
2
+ self.addEventListener('install',e=>self.skipWaiting());
3
+ self.addEventListener('activate',e=>e.waitUntil(caches.keys().then(ks=>Promise.all(ks.filter(k=>k.startsWith('ul-')).map(k=>caches.delete(k)))).then(()=>self.clients.claim())));
4
+ // No fetch handler: every request is checked by the server.