-
Notifications
You must be signed in to change notification settings - Fork 0
/
sw.js
486 lines (416 loc) · 27.4 KB
/
sw.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
// Commonly Reset Site content caches
const BlogPagesCache = 'site-blog-index-230805-v9';
const dynamicCache = 'site-dynamic-230805-v9';
const blogCache = 'site-blog-230615-v3'; //blog images
// Satic content caches
const staticCacheName = 'site-static-220605-v2';
// Topo content caches
const topoCache_Aspotogen = 'site-topocache-aspotogen-230615';
const topoCache_Chebucto = 'site-topocache-chebucto-230615';
const topoCache_Dover = 'site-topocache-dover-230615';
const topoCache_Halifax = 'site-topocache-halifax-230615';
const topoCache_LOC = 'site-topocache-loc-230615';
const topoCache_Pennant = 'site-topocache-pennant-230615';
const topoCache_Pollys = 'site-topocache-pollys-230615';
const topoCache_Prospect = 'site-topocache-prospect-230615';
const topoCache_Sambro = 'site-topocache-sambro-230709';
const topoCache_Solitary = 'site-topocache-solitary-230615';
const topoCache_TBay = 'site-topocache-tbay-230724';
const topoCache_Unlisted = 'site-topocache-unlisted-230615';
const topoCache_Other = 'site-topo-other-230801-v4';
// Topo image caches
const topoImageCache = 'site-topoimage-2300620';
const topoImageCache_Aspotogen = 'site-topoimage-aspotogen-220309';
const topoImageCache_Chebucto = 'site-topoimage-chebucto-210602';
const topoImageCache_Dover = 'site-topoimage-dover-210918';
const topoImageCache_Halifax = 'site-topoimage-halifax-211006';
const topoImageCache_Pollys = 'site-topoimage-pollys-210518';
const topoImageCache_Prospect = 'site-topoimage-prospect-220922v2';
const topoImageCache_Sambro = 'site-topoimage-sambro-230709';
const topoImageCache_Solitary = 'site-topoimage-solitary-221030';
const topoImageCache_TBay_GV = 'site-topoimage-tbay-GV-220911';
const topoImageCache_TBay_GL = 'site-topoimage-tbay-GL-220911';
const topoImageCache_TBay_GM = 'site-topoimage-tbay-GM-230115';
const topoImageCache_TBay_GP = 'site-topoimage-tbay-GP-220911';
const topoImageCache_TBay_GRH = 'site-topoimage-tbay-GRH-220911';
const topoImageCache_TBay_GS = 'site-topoimage-tbay-GS-220911';
const topoImageCache_TBay_GW = 'site-topoimage-tbay-GW-220911';
const topoImageCache_TBay_TBGE = 'site-topoimage-tbay-TBGE-220911';
const topoImageCache_TBay_TBHH = 'site-topoimage-tbay-TBHH-220911';
const topoImageCache_TBay_TBND = 'site-topoimage-tbay-TBND-221001';
const topoImageCache_TBay_CHMP = 'site-topoimage-tbay-CHMP-220911';
const topoImageCache_TBay_VT = 'site-topoimage-tbay-GV-220911';
const topoImageCache_Unlisted = 'site-topoimage-unlisted-210412';
const topoImageCache_Pennant = 'site-topoimage-pennant-2300614-v2';
// Seldom Reset Site content caches
const mapImageCache = 'site-map-image-cache-230502-v2'; //map images
const areaCache = 'site-area-aug2022'; //area images
const googleCache = 'site-google-v2';
const logoCache = 'site-logo-v4'; //logo images
const homeassets = [
'/',
'/index.php',
'/index.php?full=n&grade=h',
];
const assets = [
'/js/app.js',
'/style.css',
'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css',
'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/fonts/fontawesome-webfont.woff2?v=4.7.0',
'https://fonts.googleapis.com/css?family=Montserrat',
'https://fonts.googleapis.com/css?family=Roboto',
'https://fonts.googleapis.com/css?family=Inconsolata',
'/fallback.php',
'img/ico/sundial40.png',
'img/ico/sundial30.png',
'img/ico/sundial20.png',
'img/ico/sundial60.png',
'img/ico/sundial80.png',
'img/ico/sundial50.png',
'img/ico/sundial40m.png',
'img/ico/sundial30m.png',
'img/ico/sundial20m.png',
'img/ico/sundial70m.png',
'img/ico/sundial80m.png',
'img/ico/sundial60m.png',
'img/ico/sun20-75.PNG',
'img/ico/sun20-75.png',
'img/ico/windrtk.png',
'img/ico/windgrizzly.png',
'img/ico/windfull.png',
'img/ico/windfynnished.png',
'img/ico/star.png',
'img/ico/bench.png',
'img/ico/best.png',
'img/ico/gps.png',
'img/ico/poke.png',
'img/ico/risky.png',
'img/ico/sun.png',
'img/ico/sundial70.png',
'img/ico/tall.png',
'img/ico/turd.png',
'img/ico/vid.png',
'img/ico/wind.png',
'img/ico/sundial50m.png',
'img/ico/windnw.png',
'img/ico/vachesun.png',
'img/ico/vizzy.png',
'/manifest.json',
'/favicon.ico',
'/img/cpt/monero.png',
];
const limitCacheSize = (name, size) => {
caches.open(name).then(cache => {
cache.keys().then(keys => {
if(keys.length > size){
cache.delete(keys[0]).then(limitCacheSize(name, size));
}
});
});
};
self.addEventListener('install', evt => {
self.skipWaiting();
//console.log('service worker has been installed');
evt.waitUntil(
caches.open(staticCacheName).then(cache =>{
console.log('caching shell assets');
cache.addAll(assets);
})
);
});
function isCacheablePhpFile(url) {
const parsedUrl = new URL(url);
const pathName = parsedUrl.pathname;
return (
pathName.endsWith('index.php') ||
pathName.endsWith('blog.php') ||
pathName.endsWith('blogpost.php')
);
}
self.addEventListener('activate', evt => {
//console.log('service worker has been activate');
self.clients.claim()
evt.waitUntil(
caches.keys().then(keys =>{
//console.log(keys);
return Promise.all(keys
.filter(key => key !== staticCacheName && key !== dynamicCache && key !== BlogPagesCache && key !== mapImageCache && key !== googleCache && key !== areaCache && key !== blogCache && key !== logoCache && key !== topoImageCache && key !== topoImageCache_Aspotogen && key !== topoImageCache_Chebucto && key !== topoImageCache_Dover && key !== topoImageCache_Halifax && key !== topoImageCache_Pollys && key !== topoImageCache_Prospect && key !== topoImageCache_Sambro && key !== topoImageCache_Solitary && key !== topoImageCache_TBay_GV && key !== topoImageCache_TBay_GL && key !== topoImageCache_TBay_GM && key !== topoImageCache_TBay_GP && key !== topoImageCache_TBay_GRH && key !== topoImageCache_TBay_GS && key !== topoImageCache_TBay_GW && key !== topoImageCache_TBay_TBGE && key !== topoImageCache_TBay_TBHH && key !== topoImageCache_TBay_TBND && key !== topoImageCache_TBay_CHMP && key !== topoImageCache_TBay_VT && key !== topoImageCache_Unlisted && key !== topoImageCache_Pennant && key !== topoCache_Aspotogen && key !== topoCache_Chebucto && key !== topoCache_Dover && key !== topoCache_Halifax && key !== topoCache_Other && key !== topoCache_Pennant && key !== topoCache_Pollys && key !== topoCache_Prospect && key !== topoCache_Sambro && key !== topoCache_Solitary && key !== topoCache_TBay && key !== topoCache_Unlisted)
.map(key => caches.delete(key))
)
})
);
});
self.addEventListener('fetch', evt =>{
//console.log('fetch', evt);
evt.respondWith(
caches.match(evt.request).then(cacheRes =>{
return cacheRes || fetch(evt.request).then(fetchRes =>{
const requestUrl = evt.request.url;
// Check if the request is a .jpg file with _map_ in the file name
if (requestUrl.endsWith('.jpg') && requestUrl.includes('_map_')) {
return caches.open(mapImageCache).then(cache => {
cache.put(requestUrl, fetchRes.clone());
return fetchRes;
});
}
// Check if the request is for index.php, blog.php, or blogpost.php with GET parameters
if (isCacheablePhpFile(requestUrl)) {
return caches.open(BlogPagesCache).then(cache => {
cache.addAll(homeassets);
cache.put(requestUrl, fetchRes.clone());
return fetchRes;
});
}
if ((evt.request.url.indexOf('topo') > -1) && (evt.request.url.indexOf('topo=5800') > -1) || (evt.request.url.indexOf('topo=8100') > -1) && evt.request.url.indexOf('_sm.jpg') <= -1 && evt.request.url.indexOf('google') <= -1 && evt.request.url.indexOf('stats') <= -1 && evt.request.url.indexOf('/img/are/') <= -1 && evt.request.url.indexOf('/img/blo/') <= -1 && evt.request.url.indexOf('logo') <= -1 && evt.request.url.indexOf('/img/pro/') <= -1){
return caches.open(topoCache_Aspotogen).then(cache => {
cache.put(evt.request.url, fetchRes.clone());
return fetchRes;
})
}
if ((evt.request.url.indexOf('topo') > -1) && (evt.request.url.indexOf('topo=1200') > -1) || (evt.request.url.indexOf('topo=1300') > -1) || (evt.request.url.indexOf('topo=8000') > -1) || (evt.request.url.indexOf('topo=1700') > -1) || (evt.request.url.indexOf('topo=1600') > -1) || (evt.request.url.indexOf('1500') > -1) && evt.request.url.indexOf('_sm.jpg') <= -1 && evt.request.url.indexOf('google') <= -1 && evt.request.url.indexOf('stats') <= -1 && evt.request.url.indexOf('/img/are/') <= -1 && evt.request.url.indexOf('/img/blo/') <= -1 && evt.request.url.indexOf('logo') <= -1 && evt.request.url.indexOf('/img/pro/') <= -1){
return caches.open(topoCache_Chebucto).then(cache => {
cache.put(evt.request.url, fetchRes.clone());
return fetchRes;
})
}
if ((evt.request.url.indexOf('topo') > -1) && (evt.request.url.indexOf('topo=8900') > -1) || (evt.request.url.indexOf('topo=6600') > -1) || (evt.request.url.indexOf('topo=4900') > -1) && evt.request.url.indexOf('_sm.jpg') <= -1 && evt.request.url.indexOf('google') <= -1 && evt.request.url.indexOf('stats') <= -1 && evt.request.url.indexOf('/img/are/') <= -1 && evt.request.url.indexOf('/img/blo/') <= -1 && evt.request.url.indexOf('logo') <= -1 && evt.request.url.indexOf('/img/pro/') <= -1){
return caches.open(topoCache_Halifax).then(cache => {
cache.put(evt.request.url, fetchRes.clone());
return fetchRes;
})
}
if ((evt.request.url.indexOf('topo') > -1) && (evt.request.url.indexOf('topo=5500') > -1) || (evt.request.url.indexOf('topo=5400') > -1) || (evt.request.url.indexOf('topo=5200') > -1) || (evt.request.url.indexOf('topo=5300') > -1) || (evt.request.url.indexOf('topo=4600') > -1) || (evt.request.url.indexOf('topo=4400') > -1) && evt.request.url.indexOf('_sm.jpg') <= -1 && evt.request.url.indexOf('google') <= -1 && evt.request.url.indexOf('stats') <= -1 && evt.request.url.indexOf('/img/are/') <= -1 && evt.request.url.indexOf('/img/blo/') <= -1 && evt.request.url.indexOf('logo') <= -1 && evt.request.url.indexOf('/img/pro/') <= -1){
return caches.open(topoCache_Dover).then(cache => {
cache.put(evt.request.url, fetchRes.clone());
return fetchRes;
})
}
if ((evt.request.url.indexOf('topo') > -1) && (evt.request.url.indexOf('topo=900&') > -1) || (evt.request.url.indexOf('topo=700&') > -1) || (evt.request.url.indexOf('topo=800&') > -1) || (evt.request.url.indexOf('topo=1000') > -1) || (evt.request.url.indexOf('topo=600&') > -1) || (evt.request.url.indexOf('topo=500&') > -1) || (evt.request.url.indexOf('topo=400&') > -1) && evt.request.url.indexOf('_sm.jpg') <= -1 && evt.request.url.indexOf('google') <= -1 && evt.request.url.indexOf('stats') <= -1 && evt.request.url.indexOf('/img/are/') <= -1 && evt.request.url.indexOf('/img/blo/') <= -1 && evt.request.url.indexOf('logo') <= -1 && evt.request.url.indexOf('/img/pro/') <= -1){
return caches.open(topoCache_Pollys).then(cache => {
cache.put(evt.request.url, fetchRes.clone());
return fetchRes;
})
}
if ((evt.request.url.indexOf('topo') > -1) && (evt.request.url.indexOf('topo=6500') > -1) && evt.request.url.indexOf('_sm.jpg') <= -1 && evt.request.url.indexOf('google') <= -1 && evt.request.url.indexOf('stats') <= -1 && evt.request.url.indexOf('/img/are/') <= -1 && evt.request.url.indexOf('/img/blo/') <= -1 && evt.request.url.indexOf('logo') <= -1 && evt.request.url.indexOf('/img/pro/') <= -1){
return caches.open(topoCache_Prospect).then(cache => {
cache.put(evt.request.url, fetchRes.clone());
return fetchRes;
})
}
if ((evt.request.url.indexOf('topo') > -1) && (evt.request.url.indexOf('topo=5700') > -1) || (evt.request.url.indexOf('topo=5100') > -1) || (evt.request.url.indexOf('topo=5600') > -1) || (evt.request.url.indexOf('topo=4800') > -1) || (evt.request.url.indexOf('topo=6900') > -1) || (evt.request.url.indexOf('topo=6700') > -1) && evt.request.url.indexOf('_sm.jpg') <= -1 && evt.request.url.indexOf('google') <= -1 && evt.request.url.indexOf('stats') <= -1 && evt.request.url.indexOf('/img/are/') <= -1 && evt.request.url.indexOf('/img/blo/') <= -1 && evt.request.url.indexOf('logo') <= -1 && evt.request.url.indexOf('/img/pro/') <= -1){
return caches.open(topoCache_Sambro).then(cache => {
cache.put(evt.request.url, fetchRes.clone());
return fetchRes;
})
}
if ((evt.request.url.indexOf('topo') > -1) && (evt.request.url.indexOf('topo=1100') > -1) || (evt.request.url.indexOf('topo=4700') > -1) || (evt.request.url.indexOf('topo=5600') > -1) || (evt.request.url.indexOf('topo=8100') > -1) || (evt.request.url.indexOf('topo=8100') > -1) && evt.request.url.indexOf('_sm.jpg') <= -1 && evt.request.url.indexOf('google') <= -1 && evt.request.url.indexOf('stats') <= -1 && evt.request.url.indexOf('/img/are/') <= -1 && evt.request.url.indexOf('/img/blo/') <= -1 && evt.request.url.indexOf('logo') <= -1 && evt.request.url.indexOf('/img/pro/') <= -1){
return caches.open(topoCache_Solitary).then(cache => {
cache.put(evt.request.url, fetchRes.clone());
return fetchRes;
})
}
if ((evt.request.url.indexOf('topo') > -1) && (evt.request.url.indexOf('topo=3800') > -1) || (evt.request.url.indexOf('topo=4500') > -1) || (evt.request.url.indexOf('topo=7200') > -1) || (evt.request.url.indexOf('topo=7100') > -1) || (evt.request.url.indexOf('topo=7000') > -1) || (evt.request.url.indexOf('topo=3900') > -1) || (evt.request.url.indexOf('topo=4000') > -1) || (evt.request.url.indexOf('topo=4100') > -1) || (evt.request.url.indexOf('topo=4200') > -1) || (evt.request.url.indexOf('topo=3700') > -1) || (evt.request.url.indexOf('topo=4300') > -1) || (evt.request.url.indexOf('topo=6000') > -1) || (evt.request.url.indexOf('topo=5900') > -1) && evt.request.url.indexOf('_sm.jpg') <= -1 && evt.request.url.indexOf('google') <= -1 && evt.request.url.indexOf('stats') <= -1 && evt.request.url.indexOf('/img/are/') <= -1 && evt.request.url.indexOf('/img/blo/') <= -1 && evt.request.url.indexOf('logo') <= -1 && evt.request.url.indexOf('/img/pro/') <= -1){
return caches.open(topoCache_TBay).then(cache => {
cache.put(evt.request.url, fetchRes.clone());
return fetchRes;
})
}
if ((evt.request.url.indexOf('topo') > -1) && (evt.request.url.indexOf('topo=6800') > -1) || (evt.request.url.indexOf('topo=5000') > -1) && evt.request.url.indexOf('_sm.jpg') <= -1 && evt.request.url.indexOf('google') <= -1 && evt.request.url.indexOf('stats') <= -1 && evt.request.url.indexOf('/img/are/') <= -1 && evt.request.url.indexOf('/img/blo/') <= -1 && evt.request.url.indexOf('logo') <= -1 && evt.request.url.indexOf('/img/pro/') <= -1){
return caches.open(topoCache_Unlisted).then(cache => {
cache.put(evt.request.url, fetchRes.clone());
return fetchRes;
})
}
if ((evt.request.url.indexOf('topo') > -1) && (evt.request.url.indexOf('topo=7500') > -1) || (evt.request.url.indexOf('topo=6100') > -1) || (evt.request.url.indexOf('topo=6200') > -1) || (evt.request.url.indexOf('topo=6300') > -1) || (evt.request.url.indexOf('topo=6400') > -1) && evt.request.url.indexOf('_sm.jpg') <= -1 && evt.request.url.indexOf('google') <= -1 && evt.request.url.indexOf('stats') <= -1 && evt.request.url.indexOf('/img/are/') <= -1 && evt.request.url.indexOf('/img/blo/') <= -1 && evt.request.url.indexOf('logo') <= -1 && evt.request.url.indexOf('/img/pro/') <= -1){
return caches.open(topoCache_Pennant).then(cache => {
cache.put(evt.request.url, fetchRes.clone());
return fetchRes;
})
}
if ((evt.request.url.indexOf('topo') > -1) && evt.request.url.indexOf('_sm.jpg') <= -1 && evt.request.url.indexOf('google') <= -1 && evt.request.url.indexOf('stats') <= -1 && evt.request.url.indexOf('/img/are/') <= -1 && evt.request.url.indexOf('/img/blo/') <= -1 && evt.request.url.indexOf('logo') <= -1 && evt.request.url.indexOf('/img/pro/') <= -1){
return caches.open(topoCache_Other).then(cache => {
cache.put(evt.request.url, fetchRes.clone());
return fetchRes;
})
}
if (evt.request.url.indexOf('topo') <= -1 && evt.request.url.indexOf('/img/pro/') <= -1 && evt.request.url.indexOf('_sm.jpg') <= -1 && evt.request.url.indexOf('google') <= -1 && evt.request.url.indexOf('stats') <= -1 && evt.request.url.indexOf('/img/are/') <= -1 && evt.request.url.indexOf('/img/blo/') <= -1 && evt.request.url.indexOf('logo') <= -1 && evt.request.url.indexOf('/img/pro/') <= -1){
return caches.open(dynamicCache).then(cache => {
cache.put(evt.request.url, fetchRes.clone());
limitCacheSize(dynamicCache, 50);
return fetchRes;
})
}
if (evt.request.url.indexOf('google') > -1 || evt.request.url.indexOf('stats') > -1){
return caches.open(googleCache).then(cache => {
cache.put(evt.request.url, fetchRes.clone());
return fetchRes;
})
}
if (evt.request.url.indexOf('/img/are/') > -1){
return caches.open(areaCache).then(cache => {
cache.put(evt.request.url, fetchRes.clone());
return fetchRes;
})
}
if (evt.request.url.indexOf('/img/blo/') > -1){
return caches.open(blogCache).then(cache => {
cache.put(evt.request.url, fetchRes.clone());
return fetchRes;
})
}
if (evt.request.url.indexOf('logo') > -1){
return caches.open(logoCache).then(cache => {
cache.put(evt.request.url, fetchRes.clone());
return fetchRes;
})
}
if (evt.request.url.indexOf('/img/pro/') > -1 && (evt.request.url.indexOf('/pf') > -1) || (evt.request.url.indexOf('/show') > -1)){
return caches.open(topoImageCache_Aspotogen).then(cache => {
cache.put(evt.request.url, fetchRes.clone());
return fetchRes;
})
}
if (evt.request.url.indexOf('/img/pro/') > -1 && (evt.request.url.indexOf('/DCove') > -1) || (evt.request.url.indexOf('/chaa') > -1) || (evt.request.url.indexOf('/chts') > -1) || (evt.request.url.indexOf('/cht') > -1) || (evt.request.url.indexOf('/chf') > -1) || (evt.request.url.indexOf('/chcf') > -1)){
return caches.open(topoImageCache_Chebucto).then(cache => {
cache.put(evt.request.url, fetchRes.clone());
return fetchRes;
})
}
if (evt.request.url.indexOf('/img/pro/') > -1 && (evt.request.url.indexOf('/de') > -1) || (evt.request.url.indexOf('/dw') > -1) || (evt.request.url.indexOf('/do') > -1) || (evt.request.url.indexOf('/ds2') > -1) || (evt.request.url.indexOf('/dwa') > -1) || (evt.request.url.indexOf('/dc') > -1)){
return caches.open(topoImageCache_Dover).then(cache => {
cache.put(evt.request.url, fetchRes.clone());
return fetchRes;
})
}
if (evt.request.url.indexOf('/img/pro/') > -1 && (evt.request.url.indexOf('/kl') > -1) || (evt.request.url.indexOf('/ppp') > -1) || (evt.request.url.indexOf('/yr') > -1)){
return caches.open(topoImageCache_Halifax).then(cache => {
cache.put(evt.request.url, fetchRes.clone());
return fetchRes;
})
}
if (evt.request.url.indexOf('/img/pro/') > -1 && (evt.request.url.indexOf('/pcwa') > -1) || (evt.request.url.indexOf('/pcp') > -1) || (evt.request.url.indexOf('/pcjr') > -1) || (evt.request.url.indexOf('/pcb') > -1) || (evt.request.url.indexOf('/pcdv') > -1) || (evt.request.url.indexOf('/pca') > -1) || (evt.request.url.indexOf('/pch') > -1)){
return caches.open(topoImageCache_Pollys).then(cache => {
cache.put(evt.request.url, fetchRes.clone());
return fetchRes;
})
}
if (evt.request.url.indexOf('/img/pro/') > -1 && (evt.request.url.indexOf('/pr_') > -1)){
return caches.open(topoImageCache_Prospect).then(cache => {
cache.put(evt.request.url, fetchRes.clone());
return fetchRes;
})
}
if (evt.request.url.indexOf('/img/pro/') > -1 && (evt.request.url.indexOf('/mp') > -1) || (evt.request.url.indexOf('/ccbi') > -1) || (evt.request.url.indexOf('/ccbm') > -1) || (evt.request.url.indexOf('/dh') > -1) || (evt.request.url.indexOf('/scb') > -1) || (evt.request.url.indexOf('/spr') > -1)){
return caches.open(topoImageCache_Sambro).then(cache => {
cache.put(evt.request.url, fetchRes.clone());
return fetchRes;
})
}
if (evt.request.url.indexOf('/img/pro/') > -1 && (evt.request.url.indexOf('/bb') > -1) || (evt.request.url.indexOf('/le') > -1)){
return caches.open(topoImageCache_Solitary).then(cache => {
cache.put(evt.request.url, fetchRes.clone());
return fetchRes;
})
}
// Start Terrance bay
if (evt.request.url.indexOf('/img/pro/') > -1 && (evt.request.url.indexOf('/gv') > -1)){
return caches.open(topoImageCache_TBay_GV).then(cache => {
cache.put(evt.request.url, fetchRes.clone());
return fetchRes;
})
}
if (evt.request.url.indexOf('/img/pro/') > -1 && (evt.request.url.indexOf('/gl') > -1)){
return caches.open(topoImageCache_TBay_GL).then(cache => {
cache.put(evt.request.url, fetchRes.clone());
return fetchRes;
})
}
if (evt.request.url.indexOf('/img/pro/') > -1 && (evt.request.url.indexOf('/gm') > -1)){
return caches.open(topoImageCache_TBay_GM).then(cache => {
cache.put(evt.request.url, fetchRes.clone());
return fetchRes;
})
}
if (evt.request.url.indexOf('/img/pro/') > -1 && (evt.request.url.indexOf('/gp') > -1)){
return caches.open(topoImageCache_TBay_GP).then(cache => {
cache.put(evt.request.url, fetchRes.clone());
return fetchRes;
})
}
if (evt.request.url.indexOf('/img/pro/') > -1 && (evt.request.url.indexOf('/grh') > -1)){
return caches.open(topoImageCache_TBay_GRH).then(cache => {
cache.put(evt.request.url, fetchRes.clone());
return fetchRes;
})
}
if (evt.request.url.indexOf('/img/pro/') > -1 && (evt.request.url.indexOf('/gs') > -1)){
return caches.open(topoImageCache_TBay_GS).then(cache => {
cache.put(evt.request.url, fetchRes.clone());
return fetchRes;
})
}
if (evt.request.url.indexOf('/img/pro/') > -1 && (evt.request.url.indexOf('/gw') > -1)){
return caches.open(topoImageCache_TBay_GW).then(cache => {
cache.put(evt.request.url, fetchRes.clone());
return fetchRes;
})
}
if (evt.request.url.indexOf('/img/pro/') > -1 && (evt.request.url.indexOf('/tbge') > -1)){
return caches.open(topoImageCache_TBay_TBGE).then(cache => {
cache.put(evt.request.url, fetchRes.clone());
return fetchRes;
})
}
if (evt.request.url.indexOf('/img/pro/') > -1 && (evt.request.url.indexOf('/tbhh') > -1)){
return caches.open(topoImageCache_TBay_TBHH).then(cache => {
cache.put(evt.request.url, fetchRes.clone());
return fetchRes;
})
}
if (evt.request.url.indexOf('/img/pro/') > -1 && (evt.request.url.indexOf('/tbnd') > -1)){
return caches.open(topoImageCache_TBay_TBND).then(cache => {
cache.put(evt.request.url, fetchRes.clone());
return fetchRes;
})
}
if (evt.request.url.indexOf('/img/pro/') > -1 && (evt.request.url.indexOf('/chmp') > -1)){
return caches.open(topoImageCache_TBay_CHMP).then(cache => {
cache.put(evt.request.url, fetchRes.clone());
return fetchRes;
})
}
if (evt.request.url.indexOf('/img/pro/') > -1 && (evt.request.url.indexOf('/vt') > -1)){
return caches.open(topoImageCache_TBay_VT).then(cache => {
cache.put(evt.request.url, fetchRes.clone());
return fetchRes;
})
}
// End Terrance bay
if (evt.request.url.indexOf('/img/pro/') > -1 && (evt.request.url.indexOf('/u') > -1) || (evt.request.url.indexOf('/utf') > -1)){
return caches.open(topoImageCache_Unlisted).then(cache => {
cache.put(evt.request.url, fetchRes.clone());
return fetchRes;
})
}
if (evt.request.url.indexOf('/img/pro/') > -1 && (evt.request.url.indexOf('/wpj') > -1) || (evt.request.url.indexOf('/wph') > -1) || (evt.request.url.indexOf('/wpo') > -1) || (evt.request.url.indexOf('/wpt') > -1) || (evt.request.url.indexOf('/wphh') > -1)){
return caches.open(topoImageCache_Pennant).then(cache => {
cache.put(evt.request.url, fetchRes.clone());
return fetchRes;
})
}
if (evt.request.url.indexOf('/img/pro/') > -1){
return caches.open(topoImageCache).then(cache => {
cache.put(evt.request.url, fetchRes.clone());
return fetchRes;
})
}
});
}).catch(() => {
// Fallback logic for HTML and PHP files
// ...
if (evt.request.url.indexOf('.php') > -1 || evt.request.url.indexOf('.html') > -1 ){
return caches.match('/fallback.php')
}
})
);
});