@@ -25,31 +25,18 @@ const otherManifest = [
2525 url : "/app-shell/index.html" ,
2626 } ,
2727] ;
28- const EXCLUDED_PRECACHE_URLS = new Set ( [
29- new URL ( "/icon_512x512.png" , self . location ) . href ,
30- ] ) ;
3128
3229const allManifestURLs = [ ...manifest , ...otherManifest ] . map (
3330 ( entry ) => new URL ( entry . url , self . location ) . href ,
3431) ;
35- const requiredManifestURLs = allManifestURLs . filter (
36- ( href ) => ! EXCLUDED_PRECACHE_URLS . has ( href ) ,
37- ) ;
38-
39- const optionalManifestURLs = [ ...EXCLUDED_PRECACHE_URLS ] ;
4032
4133self . addEventListener ( "install" , ( event ) => {
4234 event . waitUntil (
4335 ( async ( ) => {
4436 const cache = await caches . open ( cacheName ) ;
4537
46- // Fail install only if "required" assets fail
47- await cache . addAll ( requiredManifestURLs ) ;
48-
4938 // Optional assets: don't fail SW install if these fail
50- await Promise . allSettled (
51- optionalManifestURLs . map ( ( url ) => cache . add ( url ) ) ,
52- ) ;
39+ await Promise . allSettled ( allManifestURLs . map ( ( url ) => cache . add ( url ) ) ) ;
5340 } ) ( ) ,
5441 ) ;
5542} ) ;
@@ -60,15 +47,15 @@ self.addEventListener("activate", (event) => {
6047 // clean up those who are not listed in manifestURLs
6148 const keys = await cache . keys ( ) ;
6249 for ( const request of keys ) {
63- if ( ! requiredManifestURLs . includes ( request . url ) ) {
50+ if ( ! allManifestURLs . includes ( request . url ) ) {
6451 await cache . delete ( request ) ;
6552 }
6653 }
6754 } ) ( ) ,
6855 ) ;
6956} ) ;
7057registerRoute (
71- ( { url } ) => requiredManifestURLs . includes ( url . href ) ,
58+ ( { url } ) => allManifestURLs . includes ( url . href ) ,
7259 new NetworkFirst ( {
7360 cacheName,
7461 } ) ,
0 commit comments