Created
October 2, 2017 07:42
-
-
Save osvaldasvalutis/a56e35a82fbc89fd146d2b8e1cc3a881 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
var thirdPartyExceptions = [ | |
'https://code.jquery.com/jquery.min.js' | |
]; | |
// ... | |
event.respondWith(fetch(request).then(response => { // network | |
// cache only resources from this domain as well as the exceptions | |
if(location.origin === url.origin || | |
thirdPartyExceptions.includes(url.href)) { | |
// addToCache use | |
} | |
return response; | |
})) | |
// ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment