feat: actually cache resized imaged

This commit is contained in:
max_richter 2023-07-26 15:55:00 +02:00
parent 1a6efd945f
commit bfe4725537

View File

@ -109,17 +109,16 @@ export const handler = async (
return new Response(params, { status: 400 });
}
const imageId = `${imageUrl}.${params.width}.${params.height}`;
if (cache.has(imageId)) {
return (await cache.get(imageId)!).clone();
}
const remoteImage = await getRemoteImage(imageUrl);
if (typeof remoteImage === "string") {
return new Response(remoteImage, { status: 400 });
}
const imageId = `${imageUrl}.${params.width}.${params.height}`;
if (cache.has(imageId)) {
return (await cache.get(imageId)!).clone();
}
const response = getImageResponse(imageUrl, remoteImage, params);
cache.set(imageId, response);