Skip to content

Instantly share code, notes, and snippets.

@luke-denton-aligent
Last active November 16, 2016 04:02
Show Gist options
  • Save luke-denton-aligent/4f2e9caf3ee95b84c692871f070d75df to your computer and use it in GitHub Desktop.
Save luke-denton-aligent/4f2e9caf3ee95b84c692871f070d75df to your computer and use it in GitHub Desktop.
// Offline Web Applications course on Udacity https://classroom.udacity.com/courses/ud899
self.addEventListener('fetch', function(event) {
//Tell the browser that we're going to handle this request ourselves
//Takes a response object or a Promise, that resolves to a Response
event.respondWith(
new Response('Hello <strong class="a-winner-is-me">world</strong>', { //String is an example, this isn't the only option here
headers: {'Content-Type', 'text-html'} //Need to set the content type to make sure the HTML in the string is parsed
});
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment