From 2dc1e07b427f7ec034560dfd1a4c94462749e4f9 Mon Sep 17 00:00:00 2001 From: Anthony LC Date: Wed, 17 Sep 2025 10:29:45 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9A=97=EF=B8=8F(service-worker)=20remove=20i?= =?UTF-8?q?ndex=20from=20cache=20first=20strategy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some users reported that the app was giving a blank page, it seems to happens often after a release. It could be due to the fact that the service worker is caching the index.html file and not updating it properly after a new release. We remove the index from the cache first strategy to avoid this kind of issue. We set as well the default handler with the "StaleWhileRevalidate" strategy to force the cache to be updated in the background. --- CHANGELOG.md | 3 ++- .../impress/src/features/service-worker/service-worker.ts | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f7fbc903..ac850ced 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,9 @@ and this project adheres to ### Fixed - 🐛(backend) duplicate sub docs as root for reader users +- ⚗️(service-worker) remove index from cache first strategy #1395 - 🐛(frontend) fix 404 page when reload 403 page #1402 +- 🐛(frontend) fix legacy role computation #1376 ## [3.7.0] - 2025-09-12 @@ -47,7 +49,6 @@ and this project adheres to ### Fixed - 🐛(frontend) fix callout emoji list #1366 -- 🐛(frontend) fix legacy role computation #1376 ## [3.6.0] - 2025-09-04 diff --git a/src/frontend/apps/impress/src/features/service-worker/service-worker.ts b/src/frontend/apps/impress/src/features/service-worker/service-worker.ts index 87693b63..3e1f4357 100644 --- a/src/frontend/apps/impress/src/features/service-worker/service-worker.ts +++ b/src/frontend/apps/impress/src/features/service-worker/service-worker.ts @@ -15,6 +15,7 @@ import { NetworkFirst, NetworkFirstOptions, NetworkOnly, + StaleWhileRevalidate, StrategyOptions, } from 'workbox-strategies'; @@ -104,8 +105,6 @@ const FALLBACK = { images: '/assets/img-not-found.svg', }; const precacheResources = [ - '/', - '/index.html', '/401/', '/404/', FALLBACK.offline, @@ -255,7 +254,7 @@ registerRoute( * Cache all other files */ setDefaultHandler( - getStrategy({ + new StaleWhileRevalidate({ cacheName: getCacheNameVersion('default'), plugins: [ new CacheableResponsePlugin({ statuses: [0, 200] }),