merged cache buster and accepted current changes
This commit is contained in:
commit
15aeb887ed
3 changed files with 44 additions and 1 deletions
|
|
@ -71,6 +71,12 @@ http {
|
||||||
add_header Cache-Control "no-store, no-cache, must-revalidate";
|
add_header Cache-Control "no-store, no-cache, must-revalidate";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Force re-cache of old service-worker
|
||||||
|
location = /service-worker.js {
|
||||||
|
root /usr/share/nginx/html; # adjust if your build folder is elsewhere
|
||||||
|
add_header Cache-Control "no-store, no-cache, must-revalidate";
|
||||||
|
}
|
||||||
|
|
||||||
# Redirect old /index.html requests to new file
|
# Redirect old /index.html requests to new file
|
||||||
location = /index.html {
|
location = /index.html {
|
||||||
return 301 /indexV2.html;
|
return 301 /indexV2.html;
|
||||||
|
|
|
||||||
24
public/service-worker.js
Normal file
24
public/service-worker.js
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
// public/service-worker.js
|
||||||
|
self.addEventListener('install', () => self.skipWaiting());
|
||||||
|
|
||||||
|
self.addEventListener('activate', async () => {
|
||||||
|
// Unregister old CRA SW
|
||||||
|
const regs = await self.registration.scope ? [self.registration] : await self.clients.getRegistrations();
|
||||||
|
for (const reg of regs) {
|
||||||
|
if (reg && reg.scriptURL.endsWith('service-worker.js')) {
|
||||||
|
await reg.unregister();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear all caches
|
||||||
|
if ('caches' in self) {
|
||||||
|
const keys = await caches.keys();
|
||||||
|
for (const key of keys) {
|
||||||
|
await caches.delete(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reload all clients
|
||||||
|
const clients = await self.clients.matchAll({ type: 'window' });
|
||||||
|
clients.forEach(client => client.navigate(client.url));
|
||||||
|
});
|
||||||
|
|
@ -81,9 +81,22 @@ export default function UserWrapper(props: Props) {
|
||||||
backgroundTasksComplete: false,
|
backgroundTasksComplete: false,
|
||||||
firmware: new Map()
|
firmware: new Map()
|
||||||
})
|
})
|
||||||
|
}).catch(() => {
|
||||||
|
userAPI.getUser(user_id).then(user => {
|
||||||
|
setGlobal({
|
||||||
|
user: user ? user : User.create(),
|
||||||
|
team: globalDefault.team,
|
||||||
|
as: "",
|
||||||
|
showErrors: false,
|
||||||
|
userTeamPermissions: [],
|
||||||
|
backgroundTasksComplete: false,
|
||||||
|
firmware: new Map()
|
||||||
|
})
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
setGlobal(globalDefault)
|
setGlobal(globalDefault)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
hasFetched.current = true;
|
hasFetched.current = true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue