-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsw.js
More file actions
5 lines (5 loc) · 1.09 KB
/
Copy pathsw.js
File metadata and controls
5 lines (5 loc) · 1.09 KB
1
2
3
4
5
const CACHE='travel-log-ui-pr-v14';
const ASSETS=['./','./index.html','./flights.html','./flights/','./hotels.html','./hotels/','./app.css','./base.css','./dashboard.css','./motion.css','./loading.css','./theme-icon.css','./flight-booking.css','./flight-booking.js','./flight-details.css','./flight-details.js','./hotel-booking.css','./hotel-booking.js','./data/hotels.json','./data/hotel-history.json','./assets/china-hero.svg','./manifest.webmanifest','./icon.svg'];
self.addEventListener('install',event=>{event.waitUntil(caches.open(CACHE).then(cache=>cache.addAll(ASSETS)));self.skipWaiting()});
self.addEventListener('activate',event=>{event.waitUntil(caches.keys().then(keys=>Promise.all(keys.filter(key=>key!==CACHE).map(key=>caches.delete(key)))));self.clients.claim()});
self.addEventListener('fetch',event=>{if(event.request.method!=='GET')return;event.respondWith(fetch(event.request).then(response=>{const copy=response.clone();caches.open(CACHE).then(cache=>cache.put(event.request,copy));return response}).catch(()=>caches.match(event.request).then(cached=>cached||caches.match('./index.html'))))});