try { if ( navigator.serviceWorker && navigator.serviceWorker.getRegistrations && location.protocol === 'https:' ) { // remove all service workers navigator.serviceWorker .getRegistrations() .then(function (registrations) { if (registrations && registrations.length) { console.log('unregistering service workers'); registrations.forEach(function (registration) { registration.unregister(); }); } }); // clear caches if (caches) { caches.keys().then(function (keyList) { if (keyList && keyList.length) { console.log('deleting caches'); keyList.forEach(function (key) { if (key && key.indexOf('druntime') === 0) { caches.delete(key); } }); } }); } } } catch (err) { // not a secured location }