about summary refs log tree commit diff stats
path: root/js/lut-cam/service-worker.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/lut-cam/service-worker.js')
-rw-r--r--js/lut-cam/service-worker.js43
1 files changed, 43 insertions, 0 deletions
diff --git a/js/lut-cam/service-worker.js b/js/lut-cam/service-worker.js
new file mode 100644
index 0000000..3ed58c1
--- /dev/null
+++ b/js/lut-cam/service-worker.js
@@ -0,0 +1,43 @@
+const CACHE_NAME = 'lut-cam-cache-v1';
+const urlsToCache = [
+    '/',
+    './',
+    'index.html',
+    'lut.js',
+    'service-worker.js',
+    'android-icon-192x192.png',
+    'android-icon-512x512.png',
+    'favicon.ico',
+    'favicon-16x16.png',
+    'favicon-32x32.png',
+    'favicon-96x96.png',
+    'apple-icon-57x57.png',
+    'apple-icon-60x60.png',
+    'apple-icon-72x72.png',
+    'apple-icon-76x76.png',
+    'apple-icon-114x114.png',
+    'apple-icon-120x120.png',
+    'apple-icon-144x144.png',
+    'apple-icon-152x152.png'
+];
+
+self.addEventListener('install', event => {
+  event.waitUntil(
+    caches.open(CACHE_NAME)
+      .then(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);
+      })
+  );
+});
\ No newline at end of file