Cache extra AP objects (#6349)

* Cache extra AP objects

* Cache nodeinfo
This commit is contained in:
MeiMei 2020-05-15 21:37:09 +09:00 committed by GitHub
parent 6667b86650
commit 36fcc0d5f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 5 deletions

View file

@ -37,6 +37,6 @@ export default async (ctx: Router.RouterContext) => {
); );
ctx.body = renderActivity(rendered); ctx.body = renderActivity(rendered);
ctx.set('Cache-Control', 'private, max-age=0, must-revalidate'); ctx.set('Cache-Control', 'public, max-age=180');
setResponseType(ctx); setResponseType(ctx);
}; };

View file

@ -82,7 +82,7 @@ export default async (ctx: Router.RouterContext) => {
// index page // index page
const rendered = renderOrderedCollection(partOf, user.followersCount, `${partOf}?page=true`); const rendered = renderOrderedCollection(partOf, user.followersCount, `${partOf}?page=true`);
ctx.body = renderActivity(rendered); ctx.body = renderActivity(rendered);
ctx.set('Cache-Control', 'private, max-age=0, must-revalidate'); ctx.set('Cache-Control', 'public, max-age=180');
setResponseType(ctx); setResponseType(ctx);
} }
}; };

View file

@ -83,7 +83,7 @@ export default async (ctx: Router.RouterContext) => {
// index page // index page
const rendered = renderOrderedCollection(partOf, user.followingCount, `${partOf}?page=true`); const rendered = renderOrderedCollection(partOf, user.followingCount, `${partOf}?page=true`);
ctx.body = renderActivity(rendered); ctx.body = renderActivity(rendered);
ctx.set('Cache-Control', 'private, max-age=0, must-revalidate'); ctx.set('Cache-Control', 'public, max-age=180');
setResponseType(ctx); setResponseType(ctx);
} }
}; };

View file

@ -82,7 +82,6 @@ export default async (ctx: Router.RouterContext) => {
); );
ctx.body = renderActivity(rendered); ctx.body = renderActivity(rendered);
ctx.set('Cache-Control', 'private, max-age=0, must-revalidate');
setResponseType(ctx); setResponseType(ctx);
} else { } else {
// index page // index page
@ -91,7 +90,7 @@ export default async (ctx: Router.RouterContext) => {
`${partOf}?page=true&since_id=000000000000000000000000` `${partOf}?page=true&since_id=000000000000000000000000`
); );
ctx.body = renderActivity(rendered); ctx.body = renderActivity(rendered);
ctx.set('Cache-Control', 'private, max-age=0, must-revalidate'); ctx.set('Cache-Control', 'public, max-age=180');
setResponseType(ctx); setResponseType(ctx);
} }
}; };

View file

@ -81,6 +81,7 @@ router.get(nodeinfo2_1path, async ctx => {
const base = await nodeinfo2(); const base = await nodeinfo2();
ctx.body = { version: '2.1', ...base }; ctx.body = { version: '2.1', ...base };
ctx.set('Cache-Control', 'public, max-age=600');
}); });
router.get(nodeinfo2_0path, async ctx => { router.get(nodeinfo2_0path, async ctx => {
@ -89,6 +90,7 @@ router.get(nodeinfo2_0path, async ctx => {
delete base.software.repository; delete base.software.repository;
ctx.body = { version: '2.0', ...base }; ctx.body = { version: '2.0', ...base };
ctx.set('Cache-Control', 'public, max-age=600');
}); });
export default router; export default router;