fix: fonts not cached by service worker (#2338)

This commit is contained in:
Noel Schnierer 2020-11-04 21:09:28 +01:00 committed by GitHub
parent dcedd17f57
commit 2a20c44338
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 0 deletions

View File

@ -36,3 +36,12 @@ workbox.routing.registerNavigationRoute(
blacklist: [/^\/_/, /\/[^/?]+\.[^/]+$/],
},
);
// Cache relevant font files
workbox.routing.registerRoute(
new RegExp("/(fonts.css|.+.(ttf|woff2|otf))"),
new workbox.strategies.StaleWhileRevalidate({
cacheName: "fonts",
plugins: [new workbox.expiration.Plugin({ maxEntries: 10 })],
}),
);