Browser navigation in between app directory pages are cached and I cannot opt out #70422
Replies: 4 comments
-
This looks like the browser's bfcache https://web.dev/articles/bfcache |
Beta Was this translation helpful? Give feedback.
-
You might be correct. How can I verify this. Adding pageshow event listener doesn't work. As this does not get retriggered on navigation. Also, I tried adding |
Beta Was this translation helpful? Give feedback.
-
Wrapping children in layout in this component seem to work. Maybe I can work on it to improve and make it more predictable. |
Beta Was this translation helpful? Give feedback.
-
@priosshrsth I'm pretty sure expected caching behavior is happening here, but can you simplify your :repro: so we can confirm? |
Beta Was this translation helpful? Give feedback.
-
Link to the code that reproduces this issue
https://github.com/priosshrsth/next-cache-test
To Reproduce
/
&/contact
Current vs. Expected behavior
The homepage after browser navigation is not latest and is cached page. No code in
/page.tsx
runs and no fetch requests are made.Expected behavior: Same thing with pages route and
getServerSideProps
shows updated data. And If I putconsole.log
insidegetServerSideProps
, it runs. Also, navigation back from pages route to homepage also returns updated data. This is so bad and so wierd. I don't want to migrate my whole app to pages directory now.Provide environment information
Which area(s) are affected? (Select all that apply)
Navigation
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local), next start (local), Vercel (Deployed)
Additional context
I tested on next js 14 and 15. I have used everything like export const dynamic = 'forcedynamic', settint revalidate and everything. Nothing works. meta tag anc cache headers are also set to not cache as well.
Beta Was this translation helpful? Give feedback.
All reactions