Skip to content

Instantly share code, notes, and snippets.

@albertoperezf
Created December 6, 2017 11:09
Show Gist options
  • Save albertoperezf/ba9d9b931552afe62796257143b2de75 to your computer and use it in GitHub Desktop.
Save albertoperezf/ba9d9b931552afe62796257143b2de75 to your computer and use it in GitHub Desktop.
Service Worker template
self.addEventListener('fetch', function(event) {
// TODO: respond to all requests with an html response
// containing an element with class="a-winner-is-me".
// Ensure the Content-Type of the response is "text/html"
console.log(event.request);
event.respondWith(
new Response('<strong class="a-winner-is-me">Hello Alberto</strong>', {
headers: {
'foo': 'bar',
'content-type': 'text/html'
}
})
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment