Developer cuts Vercel CPU costs on Next.js app using server-side caching
A developer running worldcuppicks.co received a Vercel usage alert after Fluid Active CPU spiked during the World Cup knockout rounds. Investigation via Vercel Observability revealed the homepage was making two uncached database fetches on every single user visit, consuming nearly three minutes of active CPU per billing window. The fix involved wrapping both database calls with Next.js's unstable_cache, setting match data to never expire on a timer while using tag-based invalidation triggered from the admin panel on updates. Prediction stats were given a one-hour TTL as a fallback, with real-time accuracy maintained client-side via a Supabase WebSocket subscription. Disabling a Sentry tunneling route that was generating an extra function invocation on every page load also contributed to reducing the baseline CPU usage.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in