fix: version and bypass app-shell worker during native boot
This commit is contained in:
parent
2d9758593a
commit
443c7122d8
2 changed files with 8 additions and 2 deletions
|
|
@ -10,7 +10,7 @@
|
|||
* navigations are network-first with an index fallback. No API, DM or model
|
||||
* request is ever stored; only same-origin static bytes.
|
||||
*/
|
||||
const SHELL_CACHE = 'skate-spots-shell-v2';
|
||||
const SHELL_CACHE = 'skate-spots-shell-v3';
|
||||
const SHELL_ASSETS = ['/', '/index.html'];
|
||||
|
||||
self.addEventListener('install', (event) => {
|
||||
|
|
@ -39,6 +39,12 @@ self.addEventListener('fetch', (event) => {
|
|||
const url = new URL(request.url);
|
||||
if (url.origin !== self.location.origin) return;
|
||||
if (url.pathname.startsWith('/api/') || url.pathname.startsWith('/.netlify/')) return;
|
||||
// Never cache the boot guard: an old cached copy must not be able to trap
|
||||
// the app in its own stale-worker cleanup path.
|
||||
if (url.pathname === '/boot-guard.js') {
|
||||
event.respondWith(fetch(request).catch(() => caches.match(request).then((cached) => cached || Response.error())));
|
||||
return;
|
||||
}
|
||||
|
||||
if (request.mode === 'navigate') {
|
||||
event.respondWith(
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ export function registerAppServiceWorker(): void {
|
|||
started = true;
|
||||
|
||||
const register = () => {
|
||||
navigator.serviceWorker.register('/push-sw.js').catch(() => {
|
||||
navigator.serviceWorker.register('/push-sw.js', { updateViaCache: 'none' }).catch(() => {
|
||||
// Private mode / unsupported browser — the app works without it.
|
||||
});
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue