Skip to content

Commit

Permalink
fix: resolve first render white screen issue (#1482)
Browse files Browse the repository at this point in the history
- Update service worker configuration to properly handle navigation fallback
- Add proper cache control for static assets
- Improve client-side routing handling
  • Loading branch information
tomivm committed Jan 8, 2025
1 parent 608e869 commit 82f66ce
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
11 changes: 11 additions & 0 deletions public/_headers
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion public/_redirects
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/* /index.html 200
/* /index.html 200
22 changes: 14 additions & 8 deletions sw-precache-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ function mapImagesToGlobs(boards, globPrefix) {
}
});
});
console.log(
globs.forEach(glob => {
console.log(glob);
})
);
return globs;
}

Expand All @@ -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',
Expand Down Expand Up @@ -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'
};

0 comments on commit 82f66ce

Please sign in to comment.