soiz1 commited on
Commit
4df2662
Β·
1 Parent(s): dec56b4

Update sw.js

Browse files
Files changed (1) hide show
  1. sw.js +22 -0
sw.js CHANGED
@@ -47,3 +47,25 @@ self.addEventListener('fetch', (event) => {
47
  })
48
  );
49
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  })
48
  );
49
  });
50
+ self.addEventListener('fetch', (event) => {
51
+ console.log('[SW] fetch:', event.request.url);
52
+ event.respondWith(
53
+ caches.match(event.request, { ignoreSearch: true })
54
+ .then(response => {
55
+ if (response) {
56
+ console.log('[SW] キャッシγƒ₯γƒ’γƒƒγƒˆ:', event.request.url);
57
+ return response;
58
+ }
59
+ console.log('[SW] γƒγƒƒγƒˆγƒ―γƒΌγ‚―ε–εΎ—:', event.request.url);
60
+ return fetch(event.request);
61
+ })
62
+ .catch(err => {
63
+ console.error('[SW] フェッチエラー:', event.request.url, err);
64
+ return new Response('γ‚ͺフラむンでをクセスできません', {
65
+ status: 503,
66
+ statusText: 'Offline',
67
+ });
68
+ })
69
+ );
70
+ });
71
+