fix: set avatar cache control (#11163)
parent
4c861b9e67
commit
d7d7bcd651
|
@ -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;
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
Loading…
Reference in New Issue