Additional fix for 304

This commit is contained in:
Eduard Kuzmenko 2021-06-14 17:33:44 +03:00
parent 00eb061070
commit 1bcc1f7b01

View File

@ -63,12 +63,13 @@ async function requestCache(event: FetchEvent) {
return file;
}
let response = await fetch(event.request);
const headers: HeadersInit = {'Vary': '*'};
let response = await fetch(event.request, {headers});
if(isCorrectResponse(response)) {
cache.put(event.request, response.clone());
} else if(response.status === 304) { // possible fix for 304 in Safari
const url = event.request.url.replace(/\?.+$/, '') + '?' + (Math.random() * 100000 | 0);
response = await fetch(url);
response = await fetch(url, {headers});
if(isCorrectResponse(response)) {
cache.put(event.request, response.clone());
}