Skip to content

Commit 85b0c20

Browse files
committed
Unregister service workers and clear cache when updating to avoid cache issues
1 parent ea38162 commit 85b0c20

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

smo-frontend/src/components/VersionCheck.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,24 @@ const VersionCheck: FunctionComponent = () => {
1616
}
1717

1818
const handleRefresh = () => {
19+
// Unregister service workers to avoid caching issues
20+
if ("serviceWorker" in navigator) {
21+
navigator.serviceWorker.getRegistrations().then((registrations) => {
22+
for (const registration of registrations) {
23+
registration.unregister();
24+
}
25+
});
26+
}
27+
28+
// Clear caches
29+
if (globalThis.caches) {
30+
globalThis.caches.keys().then((names) => {
31+
for (const name of names) {
32+
globalThis.caches.delete(name);
33+
}
34+
});
35+
}
36+
1937
globalThis.location.reload();
2038
};
2139

0 commit comments

Comments
 (0)