Service Worker: Fix broken UI in Safari

This commit is contained in:
Alexander Zinchuk 2021-08-27 21:08:55 +03:00
parent 8edc4f90a8
commit 894ea86f91

View File

@ -7,11 +7,18 @@ export async function respondWithCache(e: FetchEvent) {
const cached = await cache.match(e.request);
if (cached) {
return cached;
if (cached.ok) {
return cached;
} else {
await cache.delete(e.request);
}
}
const remote = await fetch(e.request);
cache.put(e.request, remote.clone());
if (remote.ok) {
cache.put(e.request, remote.clone());
}
return remote;
}