From 7e4661b66870d289760380f829233a3ce848f258 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milan=20Felix=20=C5=A0ulc?= Date: Tue, 15 Oct 2024 12:20:10 +0200 Subject: [PATCH] [instafetch] update caching --- services/instafetch/api/user.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/services/instafetch/api/user.ts b/services/instafetch/api/user.ts index 3828a4a6f..028d1b053 100755 --- a/services/instafetch/api/user.ts +++ b/services/instafetch/api/user.ts @@ -2,8 +2,9 @@ import { VercelRequest, VercelResponse } from '@vercel/node'; import { IncomingMessage } from "http"; import https from "https"; -const CACHE_BROWSER = 60 * 60 * 24 * 5; // 5 day +const CACHE_BROWSER = 60 * 60 * 24 * 10; // 10 day const CACHE_CDN = 60 * 60 * 24 * 5; // 5 days +const CACHE_SWR = 60 * 60 * 24 * 2; // 2 days const INSTAHOST_URL = process.env.INSTAHOST_URL || 'http://localhost:8000'; export default async function handler(req: VercelRequest, res: VercelResponse) { @@ -39,7 +40,7 @@ export default async function handler(req: VercelRequest, res: VercelResponse) { }; res.setHeader('Content-Type', 'application/json') - res.setHeader('Cache-Control', `max-age=${CACHE_BROWSER}, s-maxage=${CACHE_CDN}, public`); + res.setHeader('Cache-Control', `max-age=${CACHE_BROWSER}, s-maxage=${CACHE_CDN}, stale-while-revalidate=${CACHE_SWR}, public`); res.send(JSON.stringify(output)); } catch (e: any) { res.statusCode = 500;