From 02e486d757c543a1212b1adee49ebfdf9e2b2b3b Mon Sep 17 00:00:00 2001 From: Benny Joo Date: Tue, 19 Aug 2025 07:54:39 -0400 Subject: [PATCH] perf: og image caching v1 (#23180) * perf: og image caching v1 * fix * fix --- apps/web/app/api/social/og/image/route.tsx | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/apps/web/app/api/social/og/image/route.tsx b/apps/web/app/api/social/og/image/route.tsx index 498e3289cf..80abcf3a9e 100644 --- a/apps/web/app/api/social/og/image/route.tsx +++ b/apps/web/app/api/social/og/image/route.tsx @@ -87,7 +87,10 @@ async function handler(req: NextRequest) { return new Response(img.body, { status: 200, - headers: { "Content-Type": "image/png", "cache-control": "max-age=0" }, + headers: { + "Content-Type": "image/png", + "Cache-Control": "public, max-age=3600, stale-while-revalidate=86400", + }, }); } catch (error) { if (error instanceof ZodError) { @@ -116,7 +119,13 @@ async function handler(req: NextRequest) { }); const img = new ImageResponse(, ogConfig); - return new Response(img.body, { status: 200, headers: { "Content-Type": "image/png" } }); + return new Response(img.body, { + status: 200, + headers: { + "Content-Type": "image/png", + "Cache-Control": "public, max-age=3600, stale-while-revalidate=86400", + }, + }); } catch (error) { if (error instanceof ZodError) { return new Response( @@ -144,7 +153,13 @@ async function handler(req: NextRequest) { const img = new ImageResponse(, ogConfig); - return new Response(img.body, { status: 200, headers: { "Content-Type": "image/png" } }); + return new Response(img.body, { + status: 200, + headers: { + "Content-Type": "image/png", + "Cache-Control": "public, max-age=3600, stale-while-revalidate=86400", + }, + }); } catch (error) { if (error instanceof ZodError) { return new Response(