Skip to content

Scheduling infrastructure for absolutely everyone.

perf: og image caching v1 (#23180)

Benny Joo02e486d757c5
diff --git a/apps/web/app/api/social/og/image/route.tsx b/apps/web/app/api/social/og/image/route.tsx
index 498e3289cf9..80abcf3a9e9 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(<App name={name} description={description} slug={slug} />, 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(<Generic title={title} description={description} />, 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(