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