2021-04-27 12:42:06 -06:00
|
|
|
cacheName = "v1"
|
2020-05-26 20:52:48 -06:00
|
|
|
|
2021-04-27 12:42:06 -06:00
|
|
|
self.addEventListener("install", e => install(e))
|
2020-05-26 20:52:48 -06:00
|
|
|
function install(event) {
|
2021-04-27 12:42:06 -06:00
|
|
|
event.waitUntil(
|
|
|
|
caches.open(cacheName)
|
|
|
|
.then(cache => {
|
|
|
|
return cache.addAll(
|
|
|
|
[
|
|
|
|
"/",
|
|
|
|
]
|
|
|
|
)
|
|
|
|
})
|
|
|
|
)
|
2020-05-26 20:52:48 -06:00
|
|
|
}
|
|
|
|
|
2021-04-27 12:42:06 -06:00
|
|
|
self.addEventListener("fetch", e => cacheFetch(e))
|
|
|
|
function cacheFetch(event) {
|
|
|
|
event.respondWith(
|
|
|
|
fetch(event.request)
|
|
|
|
.catch(() => {
|
|
|
|
return caches.match(event.request)
|
|
|
|
})
|
|
|
|
)
|
2020-05-26 20:52:48 -06:00
|
|
|
}
|