-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsw.js
1 lines (1 loc) · 832 Bytes
/
sw.js
1
const cacheName = 'dv_01'; const precacheResources = ['index.html', 'prices.html', 'infotext.html', 'tabs.html', 'cardsgrid.html', 'contacts.html', 'downloads.html']; self.addEventListener('install', (event) => { console.log('Service worker install event!'); event.waitUntil(caches.open(cacheName).then((cache) => cache.addAll(precacheResources))); }); addEventListener('activate', event => { event.waitUntil(async function() { if (self.registration.navigationPreload) { await self.registration.navigationPreload.enable(); } }()); }); addEventListener('fetch', event => { event.respondWith(async function() { const cachedResponse = await caches.match(event.request); if (cachedResponse) return cachedResponse; const response = await event.preloadResponse; if (response) return response; return fetch(event.request); }()); });