From 30e74ce09f24ae7133238c9e126dc9f032938bd6 Mon Sep 17 00:00:00 2001 From: alex <48489896+devnaumov@users.noreply.github.com> Date: Tue, 17 Sep 2024 15:44:44 +0200 Subject: [PATCH] CB-5450 purge cache if quota error happens (#2917) * CB-5450 purge cache if quota error happens * CB-5450 cache only images from the same origin * CB-5450 change window to self * CB-5450 revert purgeOnQuotaError --------- Co-authored-by: Evgenia Bezborodova <139753579+EvgeniaBzzz@users.noreply.github.com> --- webapp/packages/core-browser/src/service-worker.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/webapp/packages/core-browser/src/service-worker.ts b/webapp/packages/core-browser/src/service-worker.ts index 4849f1b029..2d104d07df 100644 --- a/webapp/packages/core-browser/src/service-worker.ts +++ b/webapp/packages/core-browser/src/service-worker.ts @@ -117,7 +117,7 @@ registerRoute( ); registerRoute( - ({ request }) => request.destination === 'image', + ({ request, url }) => url.origin === self.location.origin && request.destination === 'image', new CacheFirst({ cacheName: 'images', plugins: [ @@ -127,6 +127,7 @@ registerRoute( new ExpirationPlugin({ maxEntries: 1000, maxAgeSeconds: 7 * 24 * 60 * 60, + purgeOnQuotaError: true, }), ], }),