⚡️(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:
@@ -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)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user