#Revalidate
1 messages · Page 1 of 1 (latest)
Based on the information provided in the knowledge sources, there are a few potential reasons why you might be experiencing issues with revalidation not updating data on the frontend while working correctly on the backend. Here are some key points to consider:
-
Router Cache: The issue may be related to the client-side router cache. As mentioned in this GitHub issue comment, when client-side navigation occurs, the page is not re-rendered but loaded from the client-side router cache. You might need to use
router.refresh()to invalidate this cache. -
Inconsistent Behavior: There have been reports of inconsistent behavior with
revalidateTag()in versions above Next.js 14.2.10. As noted in this GitHub issue, the tag revalidation may not work as expected when called directly in a page component. -
Deployment Environment: Some users have reported differences in behavior between local development and deployed environments, particularly on Vercel. As mentioned in this GitHub issue, there might be discrepancies in how revalidation works in different environments.
-
Cache Configuration: Ensure that you're using the correct cache configuration in your fetch calls. As suggested in this comment, including a
revalidatetime in your cache functions might help:fetch(publicURL + "/api/get-number", { revalidate: 259200, tags: [CACHED_NUMBER_TAG] });
- Stale Time Configuration: For client-side navigation cases, you might want to consider using the
staleTimeconfiguration in yournext.config.jsfile, as suggested by a Next.js team member in this comment.
To troubleshoot your specific issue, you may need to:
- Check your Next.js version and consider updating if you're not on the latest version.
- Verify that you're calling
revalidateTag()correctly and in the appropriate place (e.g., in a server action or API route). - Implement
router.refresh()on the client-side after revalidation to ensure the latest data is fetched. - Double-check your cache configurations and consider adding explicit
revalidatetimes.