Skip to content
Permalink
main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
// Name of our cache
const cacheName = 'offline-pwa-gallery-v1';
// URLs to cache for offline mode
const urlsToCache = [
"index.html",
"images/antelope.jpg",
"images/bobcat.jpg",
"images/caracal.jpg",
"images/caribou-bulls.jpg",
"images/caribou.jpg",
"images/cheetah.jpg",
"images/coyote.jpg",
"images/ferrets.jpg",
"images/ox.jpg",
"images/tiger.jpg",
"https://cdn.skypack.dev/@ionic/core@next/css/core.css",
"https://cdn.skypack.dev/@ionic/core@next/css/ionic.bundle.css",
"https://cdn.jsdelivr.net/npm/@ionic/core/dist/ionic/ionic.esm.js",
"https://cdn.jsdelivr.net/npm/@ionic/core/dist/ionic/ionic.js",
"css/styles.css",
"sw.js",
"./"
];
// Cache files on service worker registration
self.addEventListener('install', (event) => {
event.waitUntil(
caches.open(cacheName).then((cache) => {
return cache.addAll(urlsToCache);
})
);
});
// Intercept fetch requests to serve cached assets
self.addEventListener('fetch', (event) => {
if(event.request.url.match(/^https:\/\//)){
console.log('Browser is requesting:', event.request.url);
}
event.respondWith(
caches.match(event.request).then((cachedResponse) => {
// It can update the cache to serve updated content on the next request
return cachedResponse || fetch(event.request);
})
);
});