Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@goofmint
Created August 15, 2018 07:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goofmint/746cd65a8b13f83419bec2cd43238236 to your computer and use it in GitHub Desktop.
Save goofmint/746cd65a8b13f83419bec2cd43238236 to your computer and use it in GitHub Desktop.
self.addEventListener('message', async (e) => {
const cache = await caches.open(CACHE_NAME)
switch (e.data.action) {
case 'cache':
const res = new Response(e.data.response);
cache.put(e.data.url, res);
break;
case 'delete':
cache.delete(e.data.url);
break;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment