chore: enhance PWA cache invalidation logic

This commit is contained in:
2026-02-10 17:35:05 +01:00
parent ea2e3c573b
commit b6b289cd57
2 changed files with 10 additions and 1 deletions

View File

@@ -40,7 +40,11 @@ if ('serviceWorker' in navigator) {
}
navigator.serviceWorker.addEventListener('controllerchange', triggerReload)
const checkForUpdate = () => {
navigator.serviceWorker.getRegistration().then((registration) => registration?.update())
navigator.serviceWorker.getRegistration().then((registration) => {
if (registration) {
registration.update()
}
})
}
window.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'visible') checkForUpdate()