updated service worker

This commit is contained in:
Martin Donnelly 2018-02-12 12:58:31 +00:00
parent 8d18a49bb5
commit 7014e4c1aa

View File

@ -11,7 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
const CACHE_VERSION = 1;
const dataCacheName = 'traintimesData-v1';
const cacheName = 'traintimePWA-final-1';
const filesToCache = [
@ -20,11 +20,12 @@ const filesToCache = [
'/service-worker.js',
'/manifest.json',
'/browserconfig.xml',
'/css/common.css',
'/css/style.min.css',
'/css/mui.custom.css',
'/fonts/fonts.css',
'/fonts/Roboto_Condensed-normal-400.woff',
'/fonts/Roboto_Slab-normal-400.woff',
'/fonts/gotham.css',
'/fonts/Roboto-normal-400.woff',
'/fonts/Roboto_Mono-normal-400.woff',
'/js/bundle.js',
'/js/vendor.js',
'/img/Icon-36.png',
@ -41,7 +42,7 @@ self.addEventListener('install', function(e) {
e.waitUntil(
caches.open(cacheName).then(function(cache) {
console.log('[ServiceWorker] Caching app shell');
return cache.addAll(filesToCache);
})
);
@ -54,7 +55,7 @@ self.addEventListener('activate', function(e) {
return Promise.all(keyList.map(function(key) {
if (key !== cacheName && key !== dataCacheName) {
console.log('[ServiceWorker] Removing old cache', key);
return caches.delete(key);
}
}));
@ -91,13 +92,13 @@ self.addEventListener('fetch', function(e) {
caches.open(dataCacheName).then(function(cache) {
return fetch(e.request).then(function(response) {
cache.put(e.request.url, response.clone());
return response;
});
})
);
}
else
else
/*
* The app is asking for app shell files. In this scenario the app uses the