Open willemmulder opened 3 months ago
only-cache
:-This option sets 'force-cache' if no option is provided on fetch() request. Where as default-cache sets 'force-cache' if no option is provided on fetch() request but it consider as static even after dynamic functions.
export const fetchCache = "only-cache";
@ShubhamOulkar Thanks, but I'm not sure if I understand correctly. So what I want is that all requests (also those after dynamic functions) are always cached (unless they specifically opt out using no-store), but that the cache is invalidated every 5 minutes. How would I do that in Next 14?
Note that I do use cookies/sessions/auth, so the functions are always rendered dynamically, but I do want the requests to be cached for 5 minutes.
What do you mean with the "but it consider as static even after dynamic functions." part?
Link to the code that reproduces this issue
https://codesandbox.io/p/devbox/fetchcache-issue-h6gsf2
To Reproduce
Current vs. Expected behavior
The cache is never revalidated, while it should (in this case every 5 seconds).
Note that the page is dynamic, so the issue is not that the page itself is statically rendered, but that, even when it is rendered dynamically, it uses the existing cache all the time and never revalidates.
Provide environment information
Which area(s) are affected? (Select all that apply)
Not sure
Which stage(s) are affected? (Select all that apply)
next dev (local), Vercel (Deployed)
Additional context
Same issue on CodeSandbox, which is on NextJS 15 canary. In general, the revalidate setting does not seem to work when using force-cache.