⚗️(service-worker) remove index from cache first strategy
Some users reported that the app was giving a blank page, it seems to happens often after a release. It could be due to the fact that the service worker is caching the index.html file and not updating it properly after a new release. We remove the index from the cache first strategy to avoid this kind of issue. We set as well the default handler with the "StaleWhileRevalidate" strategy to force the cache to be updated in the background.
This commit is contained in:
@@ -15,6 +15,7 @@ import {
|
||||
NetworkFirst,
|
||||
NetworkFirstOptions,
|
||||
NetworkOnly,
|
||||
StaleWhileRevalidate,
|
||||
StrategyOptions,
|
||||
} from 'workbox-strategies';
|
||||
|
||||
@@ -104,8 +105,6 @@ const FALLBACK = {
|
||||
images: '/assets/img-not-found.svg',
|
||||
};
|
||||
const precacheResources = [
|
||||
'/',
|
||||
'/index.html',
|
||||
'/401/',
|
||||
'/404/',
|
||||
FALLBACK.offline,
|
||||
@@ -255,7 +254,7 @@ registerRoute(
|
||||
* Cache all other files
|
||||
*/
|
||||
setDefaultHandler(
|
||||
getStrategy({
|
||||
new StaleWhileRevalidate({
|
||||
cacheName: getCacheNameVersion('default'),
|
||||
plugins: [
|
||||
new CacheableResponsePlugin({ statuses: [0, 200] }),
|
||||
|
||||
Reference in New Issue
Block a user