mirror of
https://github.com/Southampton-RSG/breccia-mapper.git
synced 2026-03-03 11:27:09 +00:00
25 lines
610 B
JavaScript
25 lines
610 B
JavaScript
var staticCacheName = "djangopwa-v1";
|
|
|
|
self.addEventListener("install", function (event) {
|
|
event.waitUntil(
|
|
caches.open(staticCacheName).then(function (cache) {
|
|
return cache.addAll([""]);
|
|
})
|
|
);
|
|
});
|
|
|
|
self.addEventListener("fetch", function (event) {
|
|
var requestUrl = new URL(event.request.url);
|
|
if (requestUrl.origin === location.origin) {
|
|
if (requestUrl.pathname === "/") {
|
|
event.respondWith(caches.match(""));
|
|
return;
|
|
}
|
|
}
|
|
event.respondWith(
|
|
caches.match(event.request).then(function (response) {
|
|
return response || fetch(event.request);
|
|
})
|
|
);
|
|
});
|