fetch with next.tags and revalidateTag() not working #78501
Replies: 1 comment 3 replies
-
Hey @assad-skipbau, Could be of no help at all, but just some thoughts. 1. Cache skipped in dev:
…is normal during dev. To really test caching, try running the app in production mode ( 2. First request always skipped: 3.
4. Static generation note: export const revalidate = 60; That tells Next to re-gen the page in the background after 60s. Otherwise, it stays frozen. |
Beta Was this translation helpful? Give feedback.
-
Summary
Using next.tags in a fetch request within a server component (SSR) page does not seem to trigger caching as expected.
during development every request logs:
If I switch to using:
fetch(url, { cache: "force-cache" })
…it appears to cache the response after the first request, but the first request always shows:
I've also set up an API route that calls revalidateTag("orders"), but it has no effect — the request doesn’t re-fetch or invalidate.
On build, the page is statically generated and does not re-fetch whatsoever.
My Component:
The Aim is to have a cached data until a request comes from a second server to trigger revalidation of the data (this happens once new data inserted). The best approach is to have the request cached via tags, since one user can have new data while other not.
Additional information
Beta Was this translation helpful? Give feedback.
All reactions