···2222// INSTALL
2323////////////////////////////////////////////
24242525-self.addEventListener("install", () => {
2525+self.addEventListener("install", (_event) => {
2626 // Activate immediately without waiting for existing clients to close.
2727- thyself.skipWaiting();
2727+ /** @type {ExtendableEvent} */ (_event).waitUntil(thyself.skipWaiting());
2828});
29293030////////////////////////////////////////////
···3232////////////////////////////////////////////
33333434self.addEventListener("activate", (event) => {
3535- // Take control of all open clients right away.
3636- /** @type {ExtendableEvent} */ (event).waitUntil(thyself.clients.claim());
3535+ // Take control of all open clients right away, then reload them so every
3636+ // page starts fresh under the new service worker with no mid-session split.
3737+ /** @type {ExtendableEvent} */ (event).waitUntil(
3838+ thyself.clients.claim().then(() =>
3939+ thyself.clients.matchAll({ type: "window" }).then((clients) => {
4040+ for (const client of clients) client.navigate(client.url);
4141+ })
4242+ )
4343+ );
3744});
38453946////////////////////////////////////////////
···187194188195 // Cache full successful responses, including opaque cross-origin ones.
189196 if (response.status === 200 || response.type === "opaque") {
190190- store(request, response.clone());
197197+ store(request, response.clone()).catch(() => {});
191198 }
192199193200 return response;