As mentioned in other posts, I’ve solved this adding the next code to the register-server-worker.js
:
updated (registration) { // registration -> a ServiceWorkerRegistration instance
console.log('New content is available; please refresh.')
Notify.create({
message: i18n.t('messages.update_available'),
icon: 'cloud_download',
closeBtn: i18n.t('labels.update'),
timeout: 10000,
onDismiss () {
location.reload(true)
}
})
}
But as you want to update immediately, you must take control of the service worker lifecycle using skipWaiting()
.
Add the next code to your custom-service-worker.js
if you are using one like me:
workbox.core.skipWaiting();
But, if you are using the default configuration, add the next to the quasar.conf.js
file that will add for you:
pwa: {
workboxOptions: { skipWaiting: true }, // only for NON InjectManifest
}
If you don’t add this skip, your app will enter in a endless loop asking for update if you try to reload.