mirror of
https://github.com/cse110-fa22-group29/cse110-fa22-group29.git
synced 2024-12-26 17:09:09 +00:00
implement fix for strange first load cache behavior
This commit is contained in:
parent
d95f0036ac
commit
1ed46b8ade
@ -34,12 +34,15 @@ self.addEventListener("install", async () => {
|
||||
});
|
||||
|
||||
self.addEventListener("fetch", (event) => {
|
||||
console.log(`fetching: ${event.request.url}`);
|
||||
event.respondWith(caches.open(CACHE_NAME).then((cache) => {
|
||||
return fetch(event.request).then((fetchedResponse) => {
|
||||
cache.put(event.request, fetchedResponse.clone());
|
||||
console.log(typeof(fetchedResponse));
|
||||
return fetchedResponse;
|
||||
}).catch(() => {
|
||||
return cache.match(event.request);
|
||||
console.log(cache.match(event.request, {ignoreVary: true}));
|
||||
return cache.match(event.request, {ignoreVary: true});
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user