11console . log ( 'SW loaded' ) ;
22
3- const CACHE_NAME = 'compass-cache-v1' ;
3+ // const CACHE_NAME = 'compass-cache-v1';
44
55self . addEventListener ( 'install' , ( event ) => {
66 console . log ( 'SW installing…' ) ;
@@ -12,26 +12,26 @@ self.addEventListener('activate', (event) => {
1212} ) ;
1313
1414self . addEventListener ( 'fetch' , ( event ) => {
15- const url = new URL ( event . request . url ) ;
16-
17- // Ignore Next.js dev HMR and static chunks
18- if ( url . pathname . startsWith ( '/_next/' ) || url . pathname . startsWith ( '/__next/' ) ) {
19- return ;
20- }
21-
22- event . respondWith (
23- caches . match ( event . request ) . then ( ( cachedResponse ) => {
24- if ( cachedResponse ) return cachedResponse ;
25-
26- return fetch ( event . request ) . then ( ( networkResponse ) => {
27- return caches . open ( CACHE_NAME ) . then ( ( cache ) => {
28- // Only cache GET requests to same-origin
29- if ( event . request . method === 'GET' && event . request . url . startsWith ( self . location . origin ) ) {
30- cache . put ( event . request , networkResponse . clone ( ) ) ;
31- }
32- return networkResponse ;
33- } ) ;
34- } ) ;
35- } )
36- ) ;
15+ // const url = new URL(event.request.url);
16+ //
17+ // // Ignore Next.js dev HMR and static chunks
18+ // if (url.pathname.startsWith('/_next/') || url.pathname.startsWith('/__next/')) {
19+ // return;
20+ // }
21+ //
22+ // event.respondWith(
23+ // caches.match(event.request).then((cachedResponse) => {
24+ // if (cachedResponse) return cachedResponse;
25+ //
26+ // return fetch(event.request).then((networkResponse) => {
27+ // return caches.open(CACHE_NAME).then((cache) => {
28+ // // Only cache GET requests to same-origin
29+ // if (event.request.method === 'GET' && event.request.url.startsWith(self.location.origin)) {
30+ // cache.put(event.request, networkResponse.clone());
31+ // }
32+ // return networkResponse;
33+ // });
34+ // });
35+ // })
36+ // );
3737} ) ;
0 commit comments