Spaces:
Running
Running
Update p1/sw.js
Browse files
p1/sw.js
CHANGED
|
@@ -74,7 +74,9 @@ self.addEventListener('install', (event) => {
|
|
| 74 |
console.log('response.status:', response.status);
|
| 75 |
console.log('response.url:', response.url);
|
| 76 |
|
| 77 |
-
|
|
|
|
|
|
|
| 78 |
|
| 79 |
console.log('cache.put success');
|
| 80 |
|
|
@@ -222,7 +224,7 @@ async function handleRequest(req) {
|
|
| 222 |
|
| 223 |
console.error('network failed:', networkErr);
|
| 224 |
|
| 225 |
-
const cacheResp = await cache.match(req);
|
| 226 |
|
| 227 |
if (cacheResp) {
|
| 228 |
|
|
@@ -270,7 +272,12 @@ async function handleRequest(req) {
|
|
| 270 |
|
| 271 |
try {
|
| 272 |
|
| 273 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 274 |
|
| 275 |
if (cacheResp) {
|
| 276 |
|
|
@@ -429,7 +436,9 @@ self.addEventListener('message', (event) => {
|
|
| 429 |
console.log('response.type:', response.type);
|
| 430 |
console.log('response.status:', response.status);
|
| 431 |
|
| 432 |
-
|
|
|
|
|
|
|
| 433 |
|
| 434 |
console.log('cache.put success');
|
| 435 |
|
|
|
|
| 74 |
console.log('response.status:', response.status);
|
| 75 |
console.log('response.url:', response.url);
|
| 76 |
|
| 77 |
+
const request = new Request(file);
|
| 78 |
+
|
| 79 |
+
await cache.put(request, response);
|
| 80 |
|
| 81 |
console.log('cache.put success');
|
| 82 |
|
|
|
|
| 224 |
|
| 225 |
console.error('network failed:', networkErr);
|
| 226 |
|
| 227 |
+
const cacheResp = await cache.match(req.url);
|
| 228 |
|
| 229 |
if (cacheResp) {
|
| 230 |
|
|
|
|
| 272 |
|
| 273 |
try {
|
| 274 |
|
| 275 |
+
const normalizedUrl = new URL(req.url);
|
| 276 |
+
normalizedUrl.search = '';
|
| 277 |
+
|
| 278 |
+
const cacheResp = await cache.match(
|
| 279 |
+
normalizedUrl.pathname
|
| 280 |
+
);
|
| 281 |
|
| 282 |
if (cacheResp) {
|
| 283 |
|
|
|
|
| 436 |
console.log('response.type:', response.type);
|
| 437 |
console.log('response.status:', response.status);
|
| 438 |
|
| 439 |
+
const request = new Request(file);
|
| 440 |
+
|
| 441 |
+
await cache.put(request, response);
|
| 442 |
|
| 443 |
console.log('cache.put success');
|
| 444 |
|