Next.js Discord

Discord Forum

Caching pages on dynamic route

Unanswered
Knopper gall posted this in #help-forum
Open in Discord
Knopper gall's avatar
Knopper gallOP
On my /dashboard/customers/[id] route, I have a tabbed interface where each tab represents a subpage displaying customer data. Currently, data is refetched every time a user switches tabs. I want to optimize this to:

1. Fetch data for a subpage only when it's initially navigated to.
2. Cache this data in the browser to prevent refetching on subsequent tab switches.
3. Invalidate the cache whenever the dynamic [id] route is revisited or the page is refreshed.

Any suggestions on how I can implement this caching strategy?

0 Replies