Next.js Discord

Discord Forum

Dynamic rendering - why is router cache necessery? How to make it Infinite?

Unanswered
Siamese Crocodile posted this in #help-forum
Open in Discord
Siamese CrocodileOP
I am building an app where we use cookies and they are used in root layout where the nav is rendered so the whole app becomes dynamically rendered.

Let's say user enters homepage / and sees a <Link prefetch href="/privacy-policy" /> - the page then is prefetched not to the nearest loading boundary but fully so if it's not a long operation then the user should navigate instantly.

Then after 5 minutes the router cache expires so when we try to navigate to /privacy-policy then the nearest loading boundary is trigered and we wait e.g. 200ms while the RSC payload downloads. It's only JSX and we STILL download the RSC payload which casues a slight delay or the loading boundary is triggered - WHY?
Why can't we just mark privacy-policy as idk stale? Let user navigate backward and forward as much as he wants. No data will change there.

How can I make only /privacy-policy page content cached Infinitely in the router cache? I don't want any strange delays after (30s / 5mins) - depending on prefetch option on <Link />

So basically I'd like to have a static page with a dynamic layout which I know is not possible so lets just dynamically render /privacy-policy but do not revalidate this RSC

There is an experimental support for staleTimes and I guess that's what I want but It can be only configured for all the routes at the same time which is not desireable.

0 Replies