@newaitix

Почему Service Worker пытается получить ресурс которого нет?

resource.json
[
	"./offline.html",
	"./manifest-st.json",
	"./css/style.css",
	"./html/newpage.html",
	"./templater/popUpId.tpl",
	"./templater/bodyId.tpl",
	"./templater/topNavLog.tpl",
	"./templater/topNav.tpl",
	"./templater/bodyFailedAuth.tpl",
	"./templater/registration.tpl",
	"./templater/login.tpl",
	"./templater/syncToServ.tpl",
	"./templater/syncToPc.tpl",
	"./templater/emptySearch.tpl",
	"./templater/updateButton.tpl",
	"./templater/notification.tpl",
	"./templater/footBarData.tpl",
	"./templater/mainLog.tpl",
	"./templater/noData.tpl",
	"./resource/manifest.json",
	"./js/library.js",
	"./js/library.wp.js",
	"./js/script.js",
	"./js/sevice.js",
	"./js/conf.js",
	"./img/default-16.png",
	"./img/default-32.png",
	"./img/default-48.png",
	"./img/default-72.png",
	"./img/default-96.png",
	"./img/default-128.png",
	"./img/default-192.png",
	"./img/default-384.png",
	"./img/default-512.png",
	"./img/favicon.ico",
	"./img/load.gif"
]

sw.js
var version='5.4.0.3';
self.addEventListener('install',function(ev){
	ev.waitUntil(caches.open(version).then(function(cache){
		if(location.protocol=='http:'||location.protocol=='https:'){
			return fetch('/resource.json').then(function(res){
				return res.json();
			}).then(function(files){
				return cache.addAll(files);
			});
		}
	}));
	self.skipWaiting();
});
self.addEventListener('activate',function(ev){
	ev.waitUntil(caches.keys().then(function(keyList){
		return Promise.all(keyList.map(function(key){
			if(version!=key){
				return caches.delete(key);
			}
		}));
	}));
});
self.addEventListener('fetch',function(ev){
	ev.respondWith(caches.match(ev.request).then(function(res){
		return res||fetch(ev.request).then(function(res){
			var resToCache=res.clone();
			caches.open(version).then(function(cache){
				if(ev.request.method!='POST'){
					cache.put(ev.request,resToCache);
				}
			});
			return res;
		}).catch(function(){
			return caches.match('/offline.html');
		});
	}));
});

Получаю ошибку.
sw.js:33 Uncaught (in promise) TypeError: Failed to execute 'put' on 'Cache': Request scheme 'chrome-extension' is unsupported
    at sw.js:33

Если вывести url который sw пытается найти в кеше при ошибке то получим
chrome-extension://kpcebpgnbimlkhoindabiccelnokdpnp/dist/pageHook.js


Почему это происходит ведь список ресурсов которые нужно загрузить из кеша четко определен?
  • Вопрос задан
  • 184 просмотра
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы