Last active
November 16, 2016 04:02
-
-
Save luke-denton-aligent/55f1174b4ed2067e832d5e55788fedc3 to your computer and use it in GitHub Desktop.
This snippet will show how to send a custom response to some requests, not all
This file contains 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
// Offline Web Applications course on Udacity https://classroom.udacity.com/courses/ud899 | |
//Using example from https://gist.github.com/luke-denton/2d0f00e76151d9e4bf412df8eb1bf354 | |
// This example will replace all jpgs with superman.jpg | |
self.addEventListener('fetch', function(event) { | |
if (event.request.url.endsWith('.jpg')) { | |
event.respondWith( | |
//Any request made will receive a superman jpg as a response | |
fetch('/imgs/superman.jpg'); | |
); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment