Skip to content

Instantly share code, notes, and snippets.

@kmaraz
Created December 6, 2019 23:14
Show Gist options
  • Save kmaraz/c180c5dad9c6af825521688a7f76ec69 to your computer and use it in GitHub Desktop.
Save kmaraz/c180c5dad9c6af825521688a7f76ec69 to your computer and use it in GitHub Desktop.
workbox.routing.registerRoute(
new RegExp('/things$'),
new workbox.strategies.StaleWhileRevalidate({
cacheName: 'api-things',
plugins: [
new workbox.broadcastUpdate.Plugin({
channelName: 'api-updates',
headersToCheck: ['x-checksum'], // Or other headers
}),
new workbox.expiration.Plugin({
maxEntries: 50,
maxAgeSeconds: 30 * 24 * 60 * 60,
purgeOnQuotaError: true
}),
],
})
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment