fix: set avatar cache control (#11163)

pull/10974/head
Omar López 2023-09-06 12:22:13 -07:00 committed by GitHub
parent 4c861b9e67
commit d7d7bcd651
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View File

@ -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("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); res.send(buffer);
} catch (error) { } catch (error) {
res.statusCode = 404; res.statusCode = 404;

View File

@ -67,6 +67,8 @@ async function getIdentityData(req: NextApiRequest) {
export default async function handler(req: NextApiRequest, res: NextApiResponse) { export default async function handler(req: NextApiRequest, res: NextApiResponse) {
const identity = await getIdentityData(req); const identity = await getIdentityData(req);
const img = identity?.avatar; 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 image isn't set or links to this route itself, use default avatar
if (!img) { if (!img) {
if (identity?.org) { if (identity?.org) {