Add ignoreSearch to SW Cache fetches
This commit is contained in:
parent
a0c570c06b
commit
8e2185d185
@ -64,7 +64,7 @@
|
||||
</div>
|
||||
<!-- Footer -->
|
||||
<footer>
|
||||
<p>Created by <a href="https://fredboniface.co.uk" target="_blank" rel="noreferrer noopener">Fred Boniface</a> - 1.0.6</p>
|
||||
<p>Created by <a href="https://fredboniface.co.uk" target="_blank" rel="noreferrer noopener">Fred Boniface</a> - 1.0.7</p>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
|
54
sw.js
54
sw.js
@ -1,8 +1,8 @@
|
||||
/* Service Worker */
|
||||
|
||||
const appVersion = "1.0.6"
|
||||
const cacheName = `owlboard-${appVersion}`
|
||||
const cacheIDs = [cacheName]
|
||||
const appVersion = "1.0.7"
|
||||
const cacheName = `owlboard-${appVersion}`;
|
||||
const cacheIDs = [cacheName];
|
||||
const cacheFiles = [
|
||||
"/404.html",
|
||||
"/conn-err.html",
|
||||
@ -42,7 +42,7 @@ const cacheFiles = [
|
||||
"/images/nav/close.svg",
|
||||
"/images/nre/nre-powered_400w.webp",
|
||||
"/images/nre/nre-powered_400w.jxl"
|
||||
]
|
||||
];
|
||||
|
||||
self.addEventListener("install", (e) => {
|
||||
console.log("[Service Worker] Install");
|
||||
@ -55,28 +55,28 @@ self.addEventListener("install", (e) => {
|
||||
);
|
||||
});
|
||||
|
||||
self.addEventListener("fetch", (e) => {
|
||||
e.respondWith(
|
||||
(async () => {
|
||||
const r = await caches.match(e.request);
|
||||
if (r) {
|
||||
return r;
|
||||
}
|
||||
const response = await fetch(e.request);
|
||||
console.log(`[Service Worker] Not cached - fetching from server: ${e.request.url}`);
|
||||
return response;
|
||||
})()
|
||||
);
|
||||
});
|
||||
self.addEventListener("fetch", (e) => {
|
||||
e.respondWith(
|
||||
(async () => {
|
||||
const r = await caches.match(e.request,{ignoreSearch: true});
|
||||
if (r) {
|
||||
return r;
|
||||
}
|
||||
const response = await fetch(e.request);
|
||||
console.log(`[Service Worker] Not cached - fetching from server: ${e.request.url}`);
|
||||
return response;
|
||||
})()
|
||||
);
|
||||
});
|
||||
|
||||
self.addEventListener('activate', function (event) {
|
||||
event.waitUntil(caches.keys().then(function (keys) {
|
||||
return Promise.all(keys.filter(function (key) {
|
||||
return !cacheIDs.includes(key);
|
||||
}).map(function (key) {
|
||||
return caches.delete(key);
|
||||
}));
|
||||
}).then(function () {
|
||||
return self.clients.claim();
|
||||
self.addEventListener('activate', function (event) {
|
||||
event.waitUntil(caches.keys().then(function (keys) {
|
||||
return Promise.all(keys.filter(function (key) {
|
||||
return !cacheIDs.includes(key);
|
||||
}).map(function (key) {
|
||||
return caches.delete(key);
|
||||
}));
|
||||
});
|
||||
}).then(function () {
|
||||
return self.clients.claim();
|
||||
}));
|
||||
});
|
Reference in New Issue
Block a user