@newaitix

Как указать content-length для sw?

var config={
	mc:[
		'/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',
		'/js/library.js',
		'/js/script.js',
		'/js/sevice.js',
		'/css/style.css'
	],
	version:['v14'],
	maxAge:20000
};
self.addEventListener('activate',function(event){
	event.waitUntil(caches.keys().then(function(keyList){
		return Promise.all(keyList.map(function(key){
			if(config.version.indexOf(key)===-1)
				return caches.delete(key);
		}));
	}));
});
self.addEventListener('install', function(event) {
	event.waitUntil(caches.open(config.version).then(function(cache){
		if(location.protocol=='http:'||location.protocol=='https:')
			return cache.addAll(config.mc);
	}));
});
self.addEventListener('fetch', function(event) {
	event.respondWith(caches.match(event.request).then(function(response){
		if(response)
			return response;
		return fetch(event.request).then(function(response){
			if(!response||response.status!==200||response.type!=='basic')
				return response;
			var responseToCache=response.clone();
			caches.open(config.version).then(function(cache){
				if(event.request.url.split('://')[0]!='chrome-extension'){
					if(event.request.method!='POST')
						cache.put(event.request,responseToCache);
				}
			});
			return response;
		});
	  })
	);
});


В консоли вижу весь сохраненный контент. Но он имеет content-length - 0.
Как явно указать content-length ?
  • Вопрос задан
  • 29 просмотров
Пригласить эксперта
Ваш ответ на вопрос

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

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