Fixed service worker cache bust

This commit is contained in:
Marcus Noble 2017-10-15 08:35:38 +01:00
parent 2179f17f00
commit 4dbb6e9f26

View File

@ -1,4 +1,4 @@
var CACHE = 'v1';
var CACHE = 'v2';
self.addEventListener('fetch', function(event) {
event.respondWith(fetchAndCache(event));
@ -7,7 +7,7 @@ self.addEventListener('fetch', function(event) {
function cacheBust(request) {
var url = request.url;
if (url.indexOf(self.location.origin) >= 0) {
if (url.indexOf('.') < 0) {
if (url[url.length - 1] !== '/' && (url.indexOf('.') < 0 || url.lastIndexOf('.') < self.location.origin.length)) {
url += `/`;
}
return `${url}?${Math.random()}`;