From e3390a0bc19187f196b2df350e4f519f35338b27 Mon Sep 17 00:00:00 2001 From: Eric <5089238+emizzle@users.noreply.github.com> Date: Tue, 2 Jul 2024 16:34:24 +1000 Subject: [PATCH] aggressively cache images browser-side --- src/components/CodexImage.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/CodexImage.vue b/src/components/CodexImage.vue index ba8d328..aa6988a 100644 --- a/src/components/CodexImage.vue +++ b/src/components/CodexImage.vue @@ -51,7 +51,11 @@ async function fetchImage(cid) { let response let options = { // This will abort the fetch when either signal is aborted - signal: AbortSignal.any([controller.signal, timeoutSignal]) + signal: AbortSignal.any([controller.signal, timeoutSignal]), + // The browser looks for a matching request in its HTTP cache. + // If there is a match, fresh or stale, it will be returned from the cache. + // If there is no match, the browser will make a normal request, and will update the cache with the downloaded resource. + cache: 'force-cache' } if (props.localOnly) { response = await codexApi.downloadLocal(cid, options)