Enable cache retrieval.

This commit is contained in:
flash 2024-10-28 18:38:42 +00:00
parent 148a136bd2
commit 3b674f5e28

View file

@ -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(