feat: actually cache resized imaged
This commit is contained in:
parent
1a6efd945f
commit
bfe4725537
@ -109,17 +109,16 @@ export const handler = async (
|
|||||||
return new Response(params, { status: 400 });
|
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);
|
const remoteImage = await getRemoteImage(imageUrl);
|
||||||
if (typeof remoteImage === "string") {
|
if (typeof remoteImage === "string") {
|
||||||
return new Response(remoteImage, { status: 400 });
|
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);
|
const response = getImageResponse(imageUrl, remoteImage, params);
|
||||||
|
|
||||||
cache.set(imageId, response);
|
cache.set(imageId, response);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user