I am using GenerateSW() to add a service worker to my javascript application.
import { generateSW } from 'rollup-plugin-workbox'
import workboxConfig from './workbox-config.js'
generateSW(workboxConfig)
I would like to use the Broadcast Update feature of the service worker to notify users when a cached resource has been updated but I'm not sure how to add the plugin given my workbox config file:
import path from 'path'
const config = {
swDest: path.join(__dirname, 'dist', 'sw.js'),
globDirectory: path.join(__dirname, 'dist'),
globPatterns: ['**/*.{html,js,css,svg,png,jpg,jpeg,woff2,json}'],
runtimeCaching: [
{
handler: 'StaleWhileRevalidate',
urlPattern: /^https:\/\/.*.jwm.com\/v1\/catalogs/,
options: {
cacheName: 'catalogs',
cacheableResponse: {
statuses: [200]
},
expiration: {
maxAgeSeconds: 60 * 60
}
}
}
]
}
export default config