diff --git a/src/lib/ads.ts b/src/lib/ads.ts index 0b8ae32..de6519f 100644 --- a/src/lib/ads.ts +++ b/src/lib/ads.ts @@ -25,7 +25,11 @@ const SUPABASE_URL = process.env.NEXT_PUBLIC_SUPABASE_URL!; const SUPABASE_ANON = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!; const SCHEMA = process.env.NEXT_PUBLIC_SUPABASE_SCHEMA || "bb"; -const CACHE_TTL_MS = 5 * 60 * 1000; +// 30s in-process cache so admin uploads show on the site within ~30s. +// The /api/banners endpoint also caps at 30s, so worst-case from upload +// to live is ~60s. Was 5min, which combined with the API + CDN layers +// could push banner updates out to 15 minutes. +const CACHE_TTL_MS = 30 * 1000; type CacheRow = { rows: Ad[]; loadedAt: number }; let CACHE: CacheRow | null = null; let REFRESH_IN_FLIGHT: Promise | null = null; @@ -94,7 +98,7 @@ interface RmpBanner { async function fetchPlacement(size: Ad["size"]): Promise { try { const res = await fetch(`${RMP_API}/api/banners/${PROPERTY}/${size}`, { - next: { revalidate: 300 }, + next: { revalidate: 30 }, }); if (!res.ok) return []; const data = await res.json() as { banners?: RmpBanner[] };