From 3671344867839eeb1f4c2cdbfe15030a6b8f171f Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Wed, 8 Feb 2023 20:26:44 +0100 Subject: [PATCH 1/2] add freesound + shabda to offline cache rule --- website/astro.config.mjs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/website/astro.config.mjs b/website/astro.config.mjs index 646a3b3c..46bfd033 100644 --- a/website/astro.config.mjs +++ b/website/astro.config.mjs @@ -37,12 +37,18 @@ export default defineConfig({ globPatterns: ['**/*.{js,css,html,ico,png,svg,json,wav,mp3,ogg}'], runtimeCaching: [ { - urlPattern: /^https:\/\/raw\.githubusercontent\.com\/.*/i, + urlPattern: ({ url }) => { + [ + /^https:\/\/raw\.githubusercontent\.com\/.*/i, + /^https:\/\/freesound\.org\/.*/i, + /^https:\/\/shabda\.ndre\.gr\/.*/i, + ].some((regex) => regex.test(url)); + }, handler: 'CacheFirst', options: { cacheName: 'github-files', expiration: { - maxEntries: 200, + maxEntries: 5000, maxAgeSeconds: 60 * 60 * 24 * 30, // <== 14 days }, cacheableResponse: { @@ -53,7 +59,7 @@ export default defineConfig({ ], }, devOptions: { - enabled: true, + enabled: false, }, manifest: { includeAssets: ['favicon.ico', 'icons/apple-icon-180.png', 'favicon.svg'], From b6e42876ad94262445b6c3f810462247caa6a4bb Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Wed, 8 Feb 2023 20:32:03 +0100 Subject: [PATCH 2/2] fix cache rule + disable service worker in dev --- website/astro.config.mjs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/website/astro.config.mjs b/website/astro.config.mjs index 46bfd033..d4ef2735 100644 --- a/website/astro.config.mjs +++ b/website/astro.config.mjs @@ -37,16 +37,15 @@ export default defineConfig({ globPatterns: ['**/*.{js,css,html,ico,png,svg,json,wav,mp3,ogg}'], runtimeCaching: [ { - urlPattern: ({ url }) => { + urlPattern: ({ url }) => [ /^https:\/\/raw\.githubusercontent\.com\/.*/i, /^https:\/\/freesound\.org\/.*/i, /^https:\/\/shabda\.ndre\.gr\/.*/i, - ].some((regex) => regex.test(url)); - }, + ].some((regex) => regex.test(url)), handler: 'CacheFirst', options: { - cacheName: 'github-files', + cacheName: 'external-samples', expiration: { maxEntries: 5000, maxAgeSeconds: 60 * 60 * 24 * 30, // <== 14 days