From 36fcc0d5f6e180ed380434a121026505a523f49b Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Fri, 15 May 2020 21:37:09 +0900 Subject: [PATCH] Cache extra AP objects (#6349) * Cache extra AP objects * Cache nodeinfo --- src/server/activitypub/featured.ts | 2 +- src/server/activitypub/followers.ts | 2 +- src/server/activitypub/following.ts | 2 +- src/server/activitypub/outbox.ts | 3 +-- src/server/nodeinfo.ts | 2 ++ 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/server/activitypub/featured.ts b/src/server/activitypub/featured.ts index 32871416d..80a7852f5 100644 --- a/src/server/activitypub/featured.ts +++ b/src/server/activitypub/featured.ts @@ -37,6 +37,6 @@ export default async (ctx: Router.RouterContext) => { ); ctx.body = renderActivity(rendered); - ctx.set('Cache-Control', 'private, max-age=0, must-revalidate'); + ctx.set('Cache-Control', 'public, max-age=180'); setResponseType(ctx); }; diff --git a/src/server/activitypub/followers.ts b/src/server/activitypub/followers.ts index 0678ce6d2..d7b5a15b1 100644 --- a/src/server/activitypub/followers.ts +++ b/src/server/activitypub/followers.ts @@ -82,7 +82,7 @@ export default async (ctx: Router.RouterContext) => { // index page const rendered = renderOrderedCollection(partOf, user.followersCount, `${partOf}?page=true`); ctx.body = renderActivity(rendered); - ctx.set('Cache-Control', 'private, max-age=0, must-revalidate'); + ctx.set('Cache-Control', 'public, max-age=180'); setResponseType(ctx); } }; diff --git a/src/server/activitypub/following.ts b/src/server/activitypub/following.ts index 36c7cafaa..d39e680d9 100644 --- a/src/server/activitypub/following.ts +++ b/src/server/activitypub/following.ts @@ -83,7 +83,7 @@ export default async (ctx: Router.RouterContext) => { // index page const rendered = renderOrderedCollection(partOf, user.followingCount, `${partOf}?page=true`); ctx.body = renderActivity(rendered); - ctx.set('Cache-Control', 'private, max-age=0, must-revalidate'); + ctx.set('Cache-Control', 'public, max-age=180'); setResponseType(ctx); } }; diff --git a/src/server/activitypub/outbox.ts b/src/server/activitypub/outbox.ts index fc2a19da4..03cf65bce 100644 --- a/src/server/activitypub/outbox.ts +++ b/src/server/activitypub/outbox.ts @@ -82,7 +82,6 @@ export default async (ctx: Router.RouterContext) => { ); ctx.body = renderActivity(rendered); - ctx.set('Cache-Control', 'private, max-age=0, must-revalidate'); setResponseType(ctx); } else { // index page @@ -91,7 +90,7 @@ export default async (ctx: Router.RouterContext) => { `${partOf}?page=true&since_id=000000000000000000000000` ); ctx.body = renderActivity(rendered); - ctx.set('Cache-Control', 'private, max-age=0, must-revalidate'); + ctx.set('Cache-Control', 'public, max-age=180'); setResponseType(ctx); } }; diff --git a/src/server/nodeinfo.ts b/src/server/nodeinfo.ts index 442e946df..b0de850dd 100644 --- a/src/server/nodeinfo.ts +++ b/src/server/nodeinfo.ts @@ -81,6 +81,7 @@ router.get(nodeinfo2_1path, async ctx => { const base = await nodeinfo2(); ctx.body = { version: '2.1', ...base }; + ctx.set('Cache-Control', 'public, max-age=600'); }); router.get(nodeinfo2_0path, async ctx => { @@ -89,6 +90,7 @@ router.get(nodeinfo2_0path, async ctx => { delete base.software.repository; ctx.body = { version: '2.0', ...base }; + ctx.set('Cache-Control', 'public, max-age=600'); }); export default router;