const currentCacheName = 'KeepTrack-v2.8.1' ; const contentToCache = [ './' ] ; self . addEventListener ( 'install' , ( e ) => { e . waitUntil ( caches . open ( currentCacheName ) . then ( ( cache ) => cache . addAll ( contentToCache ) ) ) ; } ) ; self . addEventListener ( 'fetch' , ( e ) => { if ( e . request . url . startsWith ( 'https://www.google-' ) ) return ; if ( e . request . url . startsWith ( 'https://www.googletagmanager.com' ) ) return ; if ( e . request . url . startsWith ( 'https://launchlibrary.net' ) ) return ; e . respondWith ( caches . match ( e . request ) . then ( ( r ) => r || fetch ( e . request ) . then ( ( response ) => caches . open ( currentCacheName ) . then ( ( cache ) => { cache . put ( e . request , response . clone ( ) ) ; return response ; } ) ) ) ) ; } ) ; self . addEventListener ( 'activate' , function ( event ) { event . waitUntil ( caches . keys ( ) . then ( ( cacheNames ) => Promise . all ( cacheNames . forEach ( ( cacheName ) => { if ( cacheName !== currentCacheName && cacheName . startsWith ( 'KeepTrack-' ) ) { return caches . delete ( cacheName ) ; } } ) ) ) ) ; } ) ;