From 3b674f5e28ac4795548bcd7e2665531cb0fb7b01 Mon Sep 17 00:00:00 2001 From: flashwave Date: Mon, 28 Oct 2024 18:38:42 +0000 Subject: [PATCH] Enable cache retrieval. --- uiharu.ts | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/uiharu.ts b/uiharu.ts index d0a1940..1c5c636 100644 --- a/uiharu.ts +++ b/uiharu.ts @@ -718,21 +718,21 @@ const requestHandler = async (req: Request): Response => { await crypto.subtle.digest('SHA-256', new TextEncoder().encode(urlParamRaw)) ); const cacheKey = `uiharu:metadata:fv${formatVersion}:${urlHash}`; - // const cacheInfo = await cache.get(cacheKey); - // if(cacheInfo !== undefined) - // return new Response( - // brotliDecompressSync(cacheInfo.value), - // { - // status: 200, - // headers: { - // ...headers, - // ...{ - // 'Server-Timing': `metadata;dur=${(performance.now() - started).toFixed(6)}`, - // 'X-Uiharu-State': 'cache', - // }, - // }, - // } - // ); + const cacheInfo = await cache.get(cacheKey); + if(cacheInfo !== undefined) + return new Response( + brotliDecompressSync(cacheInfo.value), + { + status: 200, + headers: { + ...headers, + ...{ + 'Server-Timing': `metadata;dur=${(performance.now() - started).toFixed(6)}`, + 'X-Uiharu-State': 'cache', + }, + }, + } + ); try { const json = JSON.stringify(