Created
January 6, 2020 04:42
-
-
Save gauntface/7a1768d582bef8a3d6968ad296e3e105 to your computer and use it in GitHub Desktop.
Trying to debug sw
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function tryCache(event) { | |
console.log('Got request: ', event.request); | |
return caches.match(event.request) | |
.then((response) => { | |
if (response) { | |
console.log("Cache hit ", response); | |
return response; | |
} | |
console.log("Cache miss ", response); | |
return fetch(event.request); | |
}) | |
.catch((error) => console.error(error)); | |
} | |
self.addEventListener('fetch', (event) => { | |
event.respondWith(tryCache(event)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment