diff --git a/Russkyc.Timely/wwwroot/service-worker.published.js b/Russkyc.Timely/wwwroot/service-worker.published.js index 8925268..394cbf2 100644 --- a/Russkyc.Timely/wwwroot/service-worker.published.js +++ b/Russkyc.Timely/wwwroot/service-worker.published.js @@ -43,23 +43,16 @@ async function onActivate(event) { async function onFetch(event) { let cachedResponse = null; if (event.request.method === 'GET') { - // For all navigation requests, try to serve index.html from cache + // For all navigation requests, try to serve index.html from cache, + // unless that request is for an offline resource. // If you need some URLs to be server-rendered, edit the following check to exclude those URLs - const shouldServeIndexHtml = event.request.mode === 'navigate'; + const shouldServeIndexHtml = event.request.mode === 'navigate' + && !manifestUrlList.some(url => url === event.request.url); const request = shouldServeIndexHtml ? 'index.html' : event.request; const cache = await caches.open(cacheName); cachedResponse = await cache.match(request); - - if (cachedResponse && cachedResponse.redirected) { - cachedResponse = new Response(cachedResponse.body, - { - headers: cachedResponse.headers, - status: cachedResponse.status, - statusText: cachedResponse.statusText - }); - } } return cachedResponse || fetch(event.request); -} +} \ No newline at end of file