aboutsummaryrefslogtreecommitdiffstats
path: root/src/assets/sw.mjs
diff options
context:
space:
mode:
Diffstat (limited to 'src/assets/sw.mjs')
-rw-r--r--src/assets/sw.mjs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/assets/sw.mjs b/src/assets/sw.mjs
index 432e630..88bf684 100644
--- a/src/assets/sw.mjs
+++ b/src/assets/sw.mjs
@@ -2,7 +2,7 @@ const cache_name = "v3"
const install_sw = async event => {
const precache = async() => {
- const cache = await caches.open(cache_name);
+ const cache = await window.caches.open(cache_name);
return cache.addAll([
'/index.css',
'/prism.css',
@@ -20,11 +20,11 @@ const activate_sw = async event => {
const cachepreserve = ['v3'];
const invalidatecache = async() => {
- const keys = await caches.keys()
+ const keys = await window.caches.keys()
Promise.all(
keys.map((key) => {
if (cachepreserve.indexOf(key) === -1) {
- return caches.delete(key)
+ return window.caches.delete(key)
}
}))
}
@@ -36,17 +36,17 @@ const fetch_sw = async event => {
if (event.request.method != 'GET') {
return
}
- const cacheres = await caches.match(event.request)
+ const cacheres = await window.caches.match(event.request)
if (cacheres !== undefined) {
return cacheres
}
try {
- const response = await fetch(event.request)
- const cache = await caches.open(cache_name)
+ const response = await window.fetch(event.request)
+ const cache = await window.caches.open(cache_name)
cache.put(event.request, response.clone())
return response
} catch {
- return caches.match('/offline.html')
+ return window.caches.match('/offline.html')
}
}