perf(pwa): exclude shiki from sw precache (#907)

This commit is contained in:
Joaquín Sánchez 2023-01-09 20:34:26 +01:00 committed by GitHub
parent d0675cb391
commit 04aac652cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View file

@ -36,6 +36,19 @@ if (import.meta.env.PROD)
// only cache pages and external assets on local build + start or in production
if (import.meta.env.PROD) {
// include shiki cache
registerRoute(
({ sameOrigin, url }) =>
sameOrigin && url.pathname.startsWith('/shiki/'),
new StaleWhileRevalidate({
cacheName: 'elk-shiki',
plugins: [
new CacheableResponsePlugin({ statuses: [200] }),
// 365 days max
new ExpirationPlugin({ maxAgeSeconds: 60 * 60 * 24 * 365 }),
],
}),
)
// include emoji icons
registerRoute(
({ sameOrigin, request, url }) =>