I understand how stressful it can be when a feature works perfectly in development but fails after deployment. The knowledge sources indicate that the use cache directive currently behaves differently on Vercel compared to local development due to the serverless architecture.
Here is why your cache might be failing and how you can address it:
1. Default "Forgetful" Cache on Vercel
By default, Vercel’s dynamic use cache handler does not store entries in process memory because serverless functions run across many different processes. To preserve correctness regarding tag invalidations, the default handler essentially treats the cache as an "LRU with size 0," resulting in a miss every time for dynamic requests [Vercel "use cache" handler; Vercel "use cache" handler].
2. The Solution: use cache: remote
If you know your data (like your Supabase table) should be cached despite being in a dynamic context, you can instruct Next.js to use the remote cache layer. Users have reported that changing the directive fixes the issue on Vercel production:
'use cache: remote'
export async function fetchSupabaseData() {
}
Using "use cache: remote" instructs the framework to store the result in Vercel's remote cache layer rather than local process memory [Vercel "use cache" handler].