From 930a2b52f1233edc3cab820a10fd10cc587db92a Mon Sep 17 00:00:00 2001 From: Christiaan Arnoldus Date: Wed, 24 Jun 2026 17:12:45 +0200 Subject: [PATCH] Tune caching Snowflake data --- apps/web/src/lib/public-snowflake-report.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/web/src/lib/public-snowflake-report.ts b/apps/web/src/lib/public-snowflake-report.ts index 2d117f5eaa..21af00e3d1 100644 --- a/apps/web/src/lib/public-snowflake-report.ts +++ b/apps/web/src/lib/public-snowflake-report.ts @@ -11,7 +11,9 @@ const CORS_HEADERS = { 'Access-Control-Allow-Methods': 'GET', 'Access-Control-Allow-Headers': 'Content-Type', }; -const CACHE_TTL_SECONDS = 60; + +const VERCEL_CACHE_TTL_SECONDS = 60; +const REDIS_CACHE_TTL_SECONDS = 3600; type PublicSnowflakeReportOptions = { cacheKey: RedisKey; @@ -26,7 +28,7 @@ function successResponse(usage: Usage): NextResponse { return NextResponse.json(usage, { headers: { ...CORS_HEADERS, - 'Cache-Control': `public, s-maxage=${CACHE_TTL_SECONDS}`, + 'Cache-Control': `public, s-maxage=${VERCEL_CACHE_TTL_SECONDS}, stale-while-revalidate=${VERCEL_CACHE_TTL_SECONDS}`, }, }); } @@ -71,7 +73,7 @@ export async function getPublicSnowflakeReport({ try { await redisClient.set(cacheKey, JSON.stringify(usage), { - ex: CACHE_TTL_SECONDS, + ex: REDIS_CACHE_TTL_SECONDS, }); } catch (error) { captureException(error, {