Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
EduardZaydler committed Oct 16, 2024
1 parent 45a559e commit cd818f8
Showing 1 changed file with 3 additions and 24 deletions.
27 changes: 3 additions & 24 deletions service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,9 @@ const pagesCacheName = "pages-cache-v1";
self.addEventListener("fetch", (event) => {
const { request } = event;
const url = new URL(request.url);
console.log(request.mode);
console.log(request.redirect);
if (request.headers.get("Accept").indexOf("text/html") !== -1) {
request = new Request(url, {
method: "GET",
headers: request.headers,
mode: request.mode === "navigate" ? "cors" : request.mode,
credentials: request.credentials,
redirect: request.redirect,
});
event.respondWith(
fetch(request)
.then((response) => {
// NETWORK
// Stash a copy of this page in the pages cache
let copy = response.clone();
stashInCache(pagesCacheName, request, copy);
return response;
})
.catch(() => {
// CACHE
return caches.match(request).then((response) => response);
})
);
console.log(request.url, request.mode, request.redirect);
if (request.mode === "navigate") {
console.log("skppied navigate");
return;
}
});

0 comments on commit cd818f8

Please sign in to comment.