️(sw) stop to cache external resources likes videos

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.
This commit is contained in:
Anthony LC
2025-11-25 18:07:26 +01:00
parent 3fee1f2081
commit 785c9b21cf
2 changed files with 22 additions and 27 deletions

View File

@@ -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)
*/