From d7d7bcd65159f8228350f8f305d36d8da27c34a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Omar=20L=C3=B3pez?= Date: Wed, 6 Sep 2023 12:22:13 -0700 Subject: [PATCH] fix: set avatar cache control (#11163) --- apps/web/pages/api/logo.ts | 2 +- apps/web/pages/api/user/avatar.ts | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/web/pages/api/logo.ts b/apps/web/pages/api/logo.ts index b3e7d859a9..c7cd820765 100644 --- a/apps/web/pages/api/logo.ts +++ b/apps/web/pages/api/logo.ts @@ -187,7 +187,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) } res.setHeader("Content-Type", response.headers.get("content-type") as string); - res.setHeader("Cache-Control", "s-maxage=86400"); + res.setHeader("Cache-Control", "s-maxage=86400, stale-while-revalidate=60"); res.send(buffer); } catch (error) { res.statusCode = 404; diff --git a/apps/web/pages/api/user/avatar.ts b/apps/web/pages/api/user/avatar.ts index a3881970c8..edb6fb24b2 100644 --- a/apps/web/pages/api/user/avatar.ts +++ b/apps/web/pages/api/user/avatar.ts @@ -67,6 +67,8 @@ async function getIdentityData(req: NextApiRequest) { export default async function handler(req: NextApiRequest, res: NextApiResponse) { const identity = await getIdentityData(req); const img = identity?.avatar; + // We cache for one day + res.setHeader("Cache-Control", "s-maxage=86400, stale-while-revalidate=60"); // If image isn't set or links to this route itself, use default avatar if (!img) { if (identity?.org) {