This commit is contained in:
Bruno Windels 2020-11-05 22:31:00 +01:00
parent 16542284f3
commit c696a75f88

View File

@ -105,6 +105,10 @@ async function handleRequest(request) {
}
async function updateCache(request, response) {
// don't write error responses to the cache
if (response.status >= 400) {
return;
}
const url = new URL(request.url);
const baseURL = self.registration.scope;
if (isCacheableThumbnail(url)) {
@ -135,6 +139,11 @@ async function readCache(request) {
if (isCacheableThumbnail(url)) {
const mediaThumbnailCache = await caches.open(mediaThumbnailCacheName);
response = await mediaThumbnailCache.match(request);
// added in 0.1.26, remove previously cached error responses, remove this in some time
if (response.status >= 400) {
await mediaThumbnailCache.delete(request);
response = null;
}
}
return response;
}