Explorar o código

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

Noel Schnierer %!s(int64=4) %!d(string=hai) anos
pai
achega
2a20c44338
Modificáronse 1 ficheiros con 9 adicións e 0 borrados
  1. 9 0
      src/service-worker.js

+ 9 - 0
src/service-worker.js

@@ -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 })],
+  }),
+);