From d2f06549d147c083c9c934783c6871cd953d0135 Mon Sep 17 00:00:00 2001 From: Nicholas Jitkoff Date: Sat, 21 May 2022 12:13:56 -0700 Subject: [PATCH] Add service worker to V1 --- docs/v1/index.html | 3 ++- docs/v1/manifest.appcache | 2 +- docs/v1/worker.js | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 docs/v1/worker.js diff --git a/docs/v1/index.html b/docs/v1/index.html index 998bfea..189e8d7 100644 --- a/docs/v1/index.html +++ b/docs/v1/index.html @@ -1,9 +1,10 @@ - + diff --git a/docs/v1/manifest.appcache b/docs/v1/manifest.appcache index 36b1be0..faef146 100644 --- a/docs/v1/manifest.appcache +++ b/docs/v1/manifest.appcache @@ -1,2 +1,2 @@ CACHE MANIFEST -# itty bitty manifest 22.05.21 \ No newline at end of file +# itty bitty manifest 22.05.21 \ No newline at end of file diff --git a/docs/v1/worker.js b/docs/v1/worker.js new file mode 100644 index 0000000..0ff37e1 --- /dev/null +++ b/docs/v1/worker.js @@ -0,0 +1,20 @@ +self.addEventListener('install', function(e) { + e.waitUntil( + caches.open('ittybitty-v1').then(function(cache) { + return cache.addAll([ + '/', + '/favicon.ico' + ]); + }) + ); +}); + +self.addEventListener('fetch', function(event) { + event.respondWith( + caches.match(event.request).then(function(response) { + console.debug("Requested", event.request.url, response); + + return response || fetch(event.request); + }) + ); + }); \ No newline at end of file