Download sw.js from Wayed11/wheelie: direct link, hf CLI and curl.
- Browser
- Download file 690 Bytes
-
https://huggingface.co/spaces/Wayed11/wheelie/resolve/main/sw.js
- Command line
-
hf download hf://spaces/Wayed11/wheelie/sw.js
-
curl -L -o sw.js https://huggingface.co/spaces/Wayed11/wheelie/resolve/main/sw.js
690 Bytes
| const CACHE='wheelie-v1'; | |
| self.addEventListener('install',e=>{self.skipWaiting();e.waitUntil(caches.open(CACHE).then(c=>c.addAll(['./','manifest.json','icon-192.png','apple-touch-icon.png'])).catch(()=>{}))}); | |
| self.addEventListener('activate',e=>e.waitUntil(caches.keys().then(k=>Promise.all(k.filter(x=>x!==CACHE).map(x=>caches.delete(x)))).then(()=>self.clients.claim()))); | |
| self.addEventListener('fetch',e=>{const u=new URL(e.request.url);if(e.request.method!=='GET'||u.origin!==location.origin)return;e.respondWith(fetch(e.request).then(r=>{const c=r.clone();caches.open(CACHE).then(x=>x.put(e.request,c));return r}).catch(()=>caches.match(e.request).then(h=>h||caches.match('./'))))}); | |