var cacheName = 'jd-jaxa-gps-cache-2022-11-03b';
    var filesToCache = [
        './',
        './index.html',
        './gps.js',
        './area.json',
        './gps.css',
        './img/iimori.png',
        './img/yuza.png',
        './img/arrow.png',
        './data/yuza.geojson',
        './data/iimoriyama.geojson',
        './data/koeki.geojson',
        './data/team-1-2.geojson',
        './data/team-3-4.geojson',
        './data/team-5-6.geojson',
        './data/team-7-8.geojson',
        './data/team-9-10.geojson'
    ];
    self.addEventListener('install', function(event) {
        console.log('ServiceWorker installing');
        event.waitUntil(
    	caches.open(cacheName).then(function(cache) {
    	    console.log('Service Worker caching app shell');
    	    return cache.addAll(filesToCache);
    	})
        );
    });
    self.addEventListener('activate', function(event) {
        console.log('Service Worker activating');
        event.waitUntil(
    	caches.keys().then(function(keyList) {
    	    return Promise.all(keyList.map(function(key) {
    		if (key !== cacheName) {
    		    console.log('Service Worker removing old cache', key);
    		    return caches.delete(key);
    		}
    	    }));
    	})
        );
        return self.clients.claim();
    });
    self.addEventListener('fetch', function(event) {
        console.log('Service Worker fetching', event.request.url);
        event.respondWith(
    	caches.match(event.request).then(function(response) {
    	    return response || fetch(event.request);
    	})
        );
    });
