This commit is contained in:
fly_mc 2024-11-10 01:56:06 +08:00
parent 6dcd38e746
commit afec66841d

View file

@ -56,13 +56,13 @@ async function offlineContentHTML() {
globalThis.addEventListener('fetch', ev => {
const shouldCache = PATHS_TO_CACHE.some(path => ev.request.url.includes(path));
if (shouldCache) {
ev.respondWith(
caches.match(ev.request)
.then(response => {
if (response) return response;
return fetch(ev.request).then(response => {
if (!response || response.status !== 200 || response.type !== 'basic') return response;
const responseToCache = response.clone();
@ -251,4 +251,4 @@ globalThis.addEventListener('message', (ev: ServiceWorkerGlobalScopeEventMap['me
}
}
})());
});
});