From 82f66cee8a8d49bda19fc225d6fbc2252c1bfd7e Mon Sep 17 00:00:00 2001 From: Tomas Van Morlegan Date: Wed, 8 Jan 2025 20:21:12 +0100 Subject: [PATCH 1/2] fix: resolve first render white screen issue (#1482) - Update service worker configuration to properly handle navigation fallback - Add proper cache control for static assets - Improve client-side routing handling --- public/_headers | 11 +++++++++++ public/_redirects | 2 +- sw-precache-config.js | 22 ++++++++++++++-------- 3 files changed, 26 insertions(+), 9 deletions(-) create mode 100644 public/_headers diff --git a/public/_headers b/public/_headers new file mode 100644 index 000000000..42c9d72d7 --- /dev/null +++ b/public/_headers @@ -0,0 +1,11 @@ +/* + Cache-Control: no-cache + +/static/* + Cache-Control: public, max-age=31536000, immutable + +/*.js + Cache-Control: public, max-age=31536000, immutable + +/*.css + Cache-Control: public, max-age=31536000, immutable diff --git a/public/_redirects b/public/_redirects index 50a463356..bbb3e7a1f 100644 --- a/public/_redirects +++ b/public/_redirects @@ -1 +1 @@ -/* /index.html 200 \ No newline at end of file +/* /index.html 200 diff --git a/sw-precache-config.js b/sw-precache-config.js index 76e749f8d..90128f034 100644 --- a/sw-precache-config.js +++ b/sw-precache-config.js @@ -14,11 +14,6 @@ function mapImagesToGlobs(boards, globPrefix) { } }); }); - console.log( - globs.forEach(glob => { - console.log(glob); - }) - ); return globs; } @@ -29,11 +24,21 @@ module.exports = { staticFileGlobs: [ 'build/*.html', 'build/manifest.json', - 'build/static/**/!(*map*)', + 'build/static/**/*.*', ...boardImages ], maximumFileSizeToCacheInBytes: 4194304, runtimeCaching: [ + { + urlPattern: /\/static\//, + handler: 'cacheFirst', + options: { + cache: { + name: 'static-assets', + maxEntries: 200 + } + } + }, { urlPattern: /\/symbols\/mulberry/, handler: 'cacheFirst', @@ -62,10 +67,11 @@ module.exports = { } } ], - dontCacheBustUrlsMatching: /\.\w{8}\./, + navigateFallback: '/index.html', + navigateFallbackWhitelist: [/^\/(?!api).*/], + dontCacheBustUrlsMatching: /\.(js|css|json|jpg|jpeg|png|svg|ico)$/, dynamicUrlToDependencies: { '/': ['build/index.html'] }, - navigateFallback: '/', swFilePath: 'build/service-worker.js' }; From cbfedc8bcec0e287f6ab880972dc75300bdd0734 Mon Sep 17 00:00:00 2001 From: tomivm Date: Wed, 8 Jan 2025 20:30:56 +0100 Subject: [PATCH 2/2] fix: update CircleCI workflow branch filter for first render issue --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7773e49bd..db078c7d5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -104,4 +104,4 @@ workflows: - build filters: branches: - only: master + only: fix/1482-first-render-issue