Next.js Discord

Discord Forum

Understanding cache with a dynamic page

Unanswered
Spectacled Caiman posted this in #help-forum
Open in Discord
Spectacled CaimanOP
Hi,
I'm trying to understand exactly what is wrong with my cache setup on our NextJS v14.2.28 app.
I have a dynamic page that is querying 4 API endpoints. I use react's cache on the server to fetch the data.
These 4 endpoints have Cache-Control HTTP headers setup like this public, max-age=60, s-maxage=300, stale-while-revalidate=30.
Yet, whenever I test load my app hosted on Vercel with hey -n 10000 -c 100 https://example.com/dynamic-page I can see the API being hit at least half the time (~5k per endpoint) even though in the Vercel logs it says the cache is used:
External APIs
GET

Using cache
api.com/endpoint1
200
What am I doing wrong or misunderstanding here?
Appreciate the help 🙏

0 Replies