Skip to content

Commit 549cd3a

Browse files
committed
♻️(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.
1 parent 47572e4 commit 549cd3a

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/frontend/apps/impress/src/features/service-worker/service-worker.ts

+17
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,23 @@ setCatchHandler(async ({ request, url, event }) => {
130130
}
131131
});
132132

133+
/**
134+
* External urls cache strategy
135+
*/
136+
registerRoute(
137+
({ url }) => !url.href.includes(self.location.origin),
138+
new NetworkFirst({
139+
cacheName: getCacheNameVersion('default-external'),
140+
plugins: [
141+
new CacheableResponsePlugin({ statuses: [0, 200] }),
142+
new ExpirationPlugin({
143+
maxAgeSeconds: 24 * 60 * 60 * DAYS_EXP,
144+
}),
145+
],
146+
}),
147+
'GET',
148+
);
149+
133150
/**
134151
* Cache stategy static files images (images / svg)
135152
*/

0 commit comments

Comments
 (0)