From cda9197700b41c7ce75a3f9210df06854e7b591a Mon Sep 17 00:00:00 2001 From: Johann150 Date: Sun, 4 Dec 2022 03:26:50 +0100 Subject: [PATCH] server: increase nodeinfo caching Changelog: Changed --- packages/backend/src/server/nodeinfo.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/server/nodeinfo.ts b/packages/backend/src/server/nodeinfo.ts index 34423bd56..b06e01f90 100644 --- a/packages/backend/src/server/nodeinfo.ts +++ b/packages/backend/src/server/nodeinfo.ts @@ -107,11 +107,17 @@ const nodeinfo2 = async (): Promise => { }; }; +/* +Nodeinfo is cacheable for 1 day, the parts that change are the usage statistics +and those should not be time critical. +*/ +const cacheControl = 'public, max-age=86400'; + router.get(nodeinfo2_1path, async ctx => { const base = await nodeinfo2(); ctx.body = { version: '2.1', ...base }; - ctx.set('Cache-Control', 'public, max-age=600'); + ctx.set('Cache-Control', cacheControl); }); router.get(nodeinfo2_0path, async ctx => { @@ -120,7 +126,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'); + ctx.set('Cache-Control', cacheControl); }); export default router;