From be82e873cfde45882d271a189b8174ddc994ed17 Mon Sep 17 00:00:00 2001 From: Grzegorz Kucmierz Date: Tue, 10 Feb 2026 17:35:05 +0100 Subject: [PATCH] chore: enhance PWA cache invalidation logic --- src/main.js | 6 +++++- vite.config.js | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main.js b/src/main.js index 90a898b..e4220ad 100644 --- a/src/main.js +++ b/src/main.js @@ -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() diff --git a/vite.config.js b/vite.config.js index f2ffabc..784ecdb 100644 --- a/vite.config.js +++ b/vite.config.js @@ -12,6 +12,11 @@ export default defineConfig({ VitePWA({ registerType: 'autoUpdate', injectRegister: 'auto', + workbox: { + cleanupOutdatedCaches: true, + skipWaiting: true, + clientsClaim: true, + }, devOptions: { enabled: true },