diff --git a/icons/icon-192x192.png b/icons/icon-192x192.png new file mode 100644 index 0000000..8a099df --- /dev/null +++ b/icons/icon-192x192.png @@ -0,0 +1 @@ +placeholder 192x192 \ No newline at end of file diff --git a/icons/icon-512x512.png b/icons/icon-512x512.png new file mode 100644 index 0000000..0cc22bc --- /dev/null +++ b/icons/icon-512x512.png @@ -0,0 +1 @@ +placeholder 512x512 \ No newline at end of file diff --git a/index.html b/index.html index dd4d42d..8031a64 100644 --- a/index.html +++ b/index.html @@ -23,6 +23,7 @@ + + +
{ + event.waitUntil( + caches.open(CACHE_NAME) + .then((cache) => { + console.log('Opened cache'); + return cache.addAll(urlsToCache); + }) + ); +}); + +self.addEventListener('fetch', (event) => { + event.respondWith( + caches.match(event.request) + .then((response) => { + if (response) { + return response; + } + return fetch(event.request); + }) + ); +}); + +self.addEventListener('activate', (event) => { + const cacheWhitelist = [CACHE_NAME]; + event.waitUntil( + caches.keys().then((cacheNames) => { + return Promise.all( + cacheNames.map((cacheName) => { + if (cacheWhitelist.indexOf(cacheName) === -1) { + return caches.delete(cacheName); + } + }) + ); + }) + ); +}); \ No newline at end of file