From 785c9b21cfcb9906ebdb6b988bba214856e6e2ac Mon Sep 17 00:00:00 2001 From: Anthony LC Date: Tue, 25 Nov 2025 18:07:26 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F(sw)=20stop=20to=20cache=20ex?= =?UTF-8?q?ternal=20resources=20likes=20videos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some videos from external sources can be very large and slow to cache. To improve performance, we decided to stop caching these resources in the service worker. We will cache only images and fonts from external sources. The videos will maybe not be available when offline mode. --- CHANGELOG.md | 4 ++ .../features/service-worker/service-worker.ts | 45 ++++++++----------- 2 files changed, 22 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d603d4d..23cc2102 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ and this project adheres to - ✨ Add comments feature to the editor #1330 - ✨(backend) Comments on text editor #1330 +### Changed + +- ⚡️(sw) stop to cache external resources likes videos #1655 + ### Fixed - ♿(frontend) improve accessibility: 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 3e1f4357..da78fa24 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 @@ -157,33 +157,6 @@ registerRoute( }), ); -/** - * External urls cache strategy - */ -registerRoute( - ({ url }) => !url.href.includes(self.location.origin), - new NetworkFirst({ - cacheName: getCacheNameVersion('default-external'), - plugins: [ - new CacheableResponsePlugin({ statuses: [0, 200] }), - new ExpirationPlugin({ - maxAgeSeconds: 24 * 60 * 60 * DAYS_EXP, - }), - new OfflinePlugin(), - ], - }), - 'GET', -); - -/** - * Admin cache strategy - */ -registerRoute( - ({ url }) => - url.href.includes(self.location.origin) && url.href.includes('/admin/'), - new NetworkOnly(), -); - /** * Cache strategy static files images (images / svg) */ @@ -217,6 +190,24 @@ registerRoute( }), ); +/** + * External urls cache strategy + */ +registerRoute( + ({ url }) => !url.href.includes(self.location.origin), + new NetworkOnly(), + 'GET', +); + +/** + * Admin cache strategy + */ +registerRoute( + ({ url }) => + url.href.includes(self.location.origin) && url.href.includes('/admin/'), + new NetworkOnly(), +); + /** * Cache strategy static files (css, js, workers) */