diff --git a/app/index.html b/app/index.html
index c6b23a6..12be02c 100644
--- a/app/index.html
+++ b/app/index.html
@@ -1,6 +1,6 @@
- 🥰 🏠
+ 🥰🏠
diff --git a/package.json b/package.json
index 9f8ac21..ca13e15 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "fuzzyhome",
- "version": "0.1.8",
+ "version": "0.1.26",
"scripts": {
"start": "imba run -SMH --baseurl . -w server.imba",
"build-app": "rm -rf dist && imba build -SMH --baseurl . server.imba",
diff --git a/sw.imba b/sw.imba
index 3483da5..782a1d8 100644
--- a/sw.imba
+++ b/sw.imba
@@ -1,9 +1,9 @@
+const app_name = "fuzzyhome"
let p = console.log
import { version } from './package.json'
-const app_prefix = "fuzzyhome_cache"
-const cache_name = "{app_prefix}-{version}"
-
-p "service worker for fuzzyhome version {version}"
+const app_prefix = "{app_name}_cache"
+const cache_name = "sw-{app_prefix}-{version}"
+p cache_name
let urls = [
'./',
@@ -13,19 +13,20 @@ let urls = [
]
self.addEventListener('fetch') do |e|
+ p "{cache_name} fetch"
def intercept request
if request
- p "{cache_name} responding with cache : {e.request.url}"
+ p "{cache_name} responding with cache {e.request.url}"
request
else
- p "{cache_name} not cached, fetching : {e.request.url}"
+ p "{cache_name} not cached, fetching {e.request.url}"
fetch e.request
e.respondWith(caches.match(e.request.url).then(intercept))
self.addEventListener('install') do |e|
p "{cache_name} install"
def add_urls_to_cache cache
- p "{cache_name} installing cache : {cache_name}"
+ p "{cache_name} adding urls to cache"
cache.addAll urls
skipWaiting!
e.waitUntil(caches.open(cache_name).then(add_urls_to_cache))
@@ -34,8 +35,9 @@ self.addEventListener('activate') do |e|
p "{cache_name} activate"
def delete_cached keys
let temp = keys.map! do |key, i|
+ p "{cache_name} checking cache {key}"
if key !== cache_name
- p "{cache_name} deleting cache : {keys[i]}"
- caches.delete keys[i]
+ p "{cache_name} deleting cache {keys[i]}"
+ caches.delete key
Promise.all(temp)
e.waitUntil(caches.keys().then(delete_cached))