Skip to content

Instantly share code, notes, and snippets.

@fazlurr
Last active August 30, 2019 04:46
Show Gist options
  • Save fazlurr/a1729e39c67750ad3298018b9d6610ff to your computer and use it in GitHub Desktop.
Save fazlurr/a1729e39c67750ad3298018b9d6610ff to your computer and use it in GitHub Desktop.
workbox.routing.registerNavigationRoute('/index.html')
workbox.routing.registerRoute(
new RegExp('/path/to/api/'),
new workbox.strategies.StaleWhileRevalidate({
cacheName: 'api-cache',
plugins: [
new workbox.cacheableResponse.Plugin({
headers: {
'X-Is-Cacheable': 'true',
},
})
]
})
);
workbox.routing.registerRoute(
new RegExp('^https://third-party\\.example\\.com/images/'),
new workbox.strategies.CacheFirst({
cacheName: 'image-cache',
plugins: [
new workbox.cacheableResponse.Plugin({
statuses: [0, 200],
})
]
})
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment