From c696a75f88cb03cd7faa8c85ce809e04f4ed2969 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 5 Nov 2020 22:31:00 +0100 Subject: [PATCH] fix #177 --- src/platform/web/service-worker.template.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/platform/web/service-worker.template.js b/src/platform/web/service-worker.template.js index 903589a8..689f6d00 100644 --- a/src/platform/web/service-worker.template.js +++ b/src/platform/web/service-worker.template.js @@ -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; }