Cache issue in Next JS 15 with App Router #86538
Unanswered
Gavrushuk
asked this question in
App Router
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Version Next JS: 15.5.2
Using App Router
Since we're using Next.js 15+, not all fetch requests are cached by default. Because of that, we explicitly added caching options:
For the posts list:
For a single post:
We also use a revalidation API endpoint where we trigger the following after a post is published, edited, or deleted:
The issue is that when a post is updated, the data is revalidated, but when navigating through our site—switching between pages such as the news feed (static), post page (dynamic), and home page (static)—we see inconsistent data.
On some pages, the post title is updated; on others, it still shows the old version. Sometimes the title on the single post page is outdated while the lists are already updated.
If we keep navigating between links, after about ~15 minutes, everything eventually syncs and shows fresh data. Additionally, if we manually refresh a page twice, only then does it display the updated content.
We're trying to decrease staleTime in the Next.js config from 5 minutes to 1 minute for static pages, but it hasn't helped.
Maybe someone has experienced this issue and successfully fixed it. Any suggestions or insights would be greatly appreciated.
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions