31 lines
639 B
JavaScript
31 lines
639 B
JavaScript
const CACHE_NAME = "woordjes-v1";
|
|
|
|
const FILES = [
|
|
"/learn.php",
|
|
"/assets/css/style.css",
|
|
"/assets/js/app.js"
|
|
];
|
|
|
|
self.addEventListener("install", (event) => {
|
|
event.waitUntil(
|
|
caches.open(CACHE_NAME).then((cache) => {
|
|
return cache.addAll(FILES);
|
|
})
|
|
);
|
|
});
|
|
|
|
self.addEventListener("fetch", (event) => {
|
|
|
|
const url = event.request.url;
|
|
|
|
// API NIET cachen (anders breekt je SRS)
|
|
if (url.includes("/api/")) {
|
|
return;
|
|
}
|
|
|
|
event.respondWith(
|
|
caches.match(event.request).then((cached) => {
|
|
return cached || fetch(event.request);
|
|
})
|
|
);
|
|
}); |