diff --git a/src/services/PreviewService.js b/src/services/PreviewService.js index 496fd095b..7a34f92af 100644 --- a/src/services/PreviewService.js +++ b/src/services/PreviewService.js @@ -27,9 +27,14 @@ const SWCacheName = 'images' * Check if the preview is already cached by the service worker * * @param {string} previewUrl - The URL of the preview to check + * @return {Promise} */ export const isCachedPreview = async function(previewUrl) { - const cache = await window.caches?.open(SWCacheName) - const response = await cache?.match(previewUrl) - return response !== undefined + try { + const cache = await window.caches?.open(SWCacheName) + const response = await cache?.match(previewUrl) + return response !== undefined + } catch { + return false + } }