-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsw.js
1 lines (1 loc) · 959 Bytes
/
sw.js
1
const cacheName="weather-v1",staticAssets=["index.html","manifest.webmanifest","assets/bootstrap.min.css","assets/style.css","assets/script.js","assets/Chart.min.js","assets/poppins.woff2","assets/image/icon.png","assets/image/icon-512.png","assets/image/icons/cloudy-day.svg","assets/image/icons/cloudy-night.svg","assets/image/icons/cloudy.svg","assets/image/icons/day.svg","assets/image/icons/mist.svg","assets/image/icons/night.svg","assets/image/icons/rainy-day.svg","assets/image/icons/rainy.svg","assets/image/icons/snow.svg","assets/image/icons/thunder.svg","/weather/"];self.addEventListener("install",async s=>{const e=await caches.open(cacheName);return await e.addAll(staticAssets),self.skipWaiting()}),self.addEventListener("activate",s=>{s.waitUntil(caches.keys().then(s=>Promise.all(s.filter(s=>s!==cacheName).map(s=>caches.delete(s)))))}),self.addEventListener("fetch",s=>{s.respondWith(caches.match(s.request).then(e=>e||fetch(s.request)))});