♻️(service-worker) external url NetworkFirst

We will use the NetworkFirst strategy
for external URLs, if a patch is made from
the external resource, the resource will be
updated directly.
This commit is contained in:
Anthony LC
2024-07-02 16:23:31 +02:00
committed by Anthony LC
parent e26b806965
commit a393cd4df0

View File

@@ -130,6 +130,23 @@ setCatchHandler(async ({ request, url, event }) => {
}
});
/**
* 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,
}),
],
}),
'GET',
);
/**
* Cache stategy static files images (images / svg)
*/