♻️(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:
@@ -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)
|
* Cache stategy static files images (images / svg)
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user