From 3667e7630b4b1414d72a697b2fe2a9db3d990633 Mon Sep 17 00:00:00 2001 From: Miodec Date: Thu, 3 Nov 2022 15:31:37 +0100 Subject: [PATCH] not precaching so aggressively using runtime caching instead using a stale while revalidate strategy caching webfonts with cache first since they will very rarely change --- frontend/webpack/config.prod.js | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/frontend/webpack/config.prod.js b/frontend/webpack/config.prod.js index f39327fa0..10d017991 100644 --- a/frontend/webpack/config.prod.js +++ b/frontend/webpack/config.prod.js @@ -87,6 +87,43 @@ const PRODUCTION_CONFIG = { /\.DS_Store/, /\.map$/, /^manifest.*\.js$/, + /languages\/.*\.json/, + /quotes\/.*\.json/, + /themes\/.*\.css/, + /challenges\/.*\.txt/, + /sound\/.*\.wav/, + /images\/.*\.(png|jpg)/, + /webfonts\/.+/, + ], + runtimeCaching: [ + { + urlPattern: /languages\/.*\.json/, + handler: "StaleWhileRevalidate", + }, + { + urlPattern: /quotes\/.*\.json/, + handler: "StaleWhileRevalidate", + }, + { + urlPattern: /themes\/.*\.css/, + handler: "StaleWhileRevalidate", + }, + { + urlPattern: /challenges\/.*\.txt/, + handler: "StaleWhileRevalidate", + }, + { + urlPattern: /sound\/.*\.wav/, + handler: "StaleWhileRevalidate", + }, + { + urlPattern: /images\/.*\.(png|jpg)/, + handler: "StaleWhileRevalidate", + }, + { + urlPattern: /webfonts\/.+/, + handler: "CacheFirst", + }, ], }), ],