Enable immediate PWA updates and cache cleanup.
Added functionality to immediately activate new Service Worker versions and reload the page upon updates. Enhanced caching configuration in Vite to clean outdated caches and ensure clients use the latest version.
This commit is contained in:
1 parent
3a66c0cf74
commit
9aa3532dd6
2 files changed
+10
No files matched your search
@@ -5,3 +5,10 @@ import { registerSW } from "virtual:pwa-register";
|
||||
|
||||
createRoot(document.getElementById("root")).render(<App />);
|
||||
registerSW({ immediate: true });
|
||||
const updateSW = registerSW({
|
||||
immediate: true,
|
||||
onNeedRefresh() {
|
||||
updateSW(true); // sofort neue Version aktivieren
|
||||
window.location.reload();
|
||||
},
|
||||
});
|
||||
@@ -28,6 +28,9 @@ export default defineConfig({
|
||||
workbox: {
|
||||
// Caching-Default: die App-Shell wird offline verfügbar
|
||||
globPatterns: ["**/*.{js,css,html,ico,png,jpg,jpeg,svg,webp}"],
|
||||
cleanupOutdatedCaches: true,
|
||||
skipWaiting: true,
|
||||
clientsClaim: true,
|
||||
}
|
||||
})
|
||||
]
|
||||
|
||||
Reference in new issue
Block a user