Created
October 2, 2017 07:30
-
-
Save osvaldasvalutis/5e1ca367481d2d8404daf701f749b3c1 to your computer and use it in GitHub Desktop.
Service Worker gotchas – https://medium.com/kollegorna/service-worker-gotchas-af20a9dab986
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
event.respondWith(caches.match(request).then(response => { | |
return response // cache-first | |
|| fetch(request).then(response => { // network | |
// ... | |
}) | |
.catch(() => { // offline | |
if(type.startsWith('image')) { | |
return new Response('<svg...', {headers: {'Content-Type': 'image/svg+xml', 'Cache-Control': 'no-store'}}); | |
} | |
else { | |
// ... | |
} | |
}); | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment