From 6f1bb9445d7a457811e0aaa27b6bfd9f49b41139 Mon Sep 17 00:00:00 2001 From: FireMasterK <20838718+FireMasterK@users.noreply.github.com> Date: Thu, 13 Jan 2022 06:30:23 +0000 Subject: [PATCH] Add runtime caching for fonts. --- vite.config.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/vite.config.js b/vite.config.js index 50b0c068..172eda93 100644 --- a/vite.config.js +++ b/vite.config.js @@ -18,6 +18,22 @@ export default defineConfig({ registerType: "autoUpdate", workbox: { globPatterns: ["**/*.{js,css,html,ico,svg,png}", "manifest.webmanifest"], + runtimeCaching: [ + { + urlPattern: /https:\/\/[a-zA-Z./0-9_]*\.(?:otf|ttf)/i, + handler: "CacheFirst", + options: { + cacheName: "fonts-cache", + expiration: { + maxEntries: 10, + maxAgeSeconds: 60 * 60 * 24 * 365, // <== 365 days + }, + cacheableResponse: { + statuses: [0, 200], + }, + }, + }, + ], }, manifest: { name: "Piped",