24 lines
503 B
JavaScript
24 lines
503 B
JavaScript
// /var/www/minitactix/static/service-worker.js
|
|
const CACHE_NAME = "minitactix-cache-v1"
|
|
const FILES_TO_CACHE = [
|
|
"/",
|
|
"/index.html",
|
|
"/style.css",
|
|
"/app.js",
|
|
"/manifest.json"
|
|
]
|
|
|
|
self.addEventListener("install", (evt) => {
|
|
evt.waitUntil(
|
|
caches.open(CACHE_NAME).then((cache) => cache.addAll(FILES_TO_CACHE))
|
|
)
|
|
self.skipWaiting()
|
|
})
|
|
|
|
self.addEventListener("fetch", (evt) => {
|
|
evt.respondWith(
|
|
caches.match(evt.request).then((response) => response || fetch(evt.request))
|
|
)
|
|
})
|
|
|