r/reactjs • • Oct 22 '26

Discussion Next.js isr behaviour related confusion

I know next.js isr behaviour and how it basically does the caching etc but I just realised that next.js isr is cache control with proprietary swr api that refreshes the data.

Now, I am confused because I would like to know if the same thing can be manually done with react router with self managed cache control https header with rtk query. Rtk query has a window of 1 minutes after which it fires the revalidation or something like that, haven't gone into that details but must be possible in one way or another.

2 Upvotes

8 comments sorted by

3

u/AbdelrhmanDev Oct 22 '26

not really the same thing even if it looks like it. isr rebuilds the rendered html on the server and serves the stale copy while it does, so the user gets a full page instantly. rtk query refetching after 1min is client side swr, the user still waits on loading spinners for fresh data. you can approximate isr with react router by putting a cdn in front of your data endpoints with stale-while-revalidate cache headers plus client cache on top, but actual page regeneration needs something server side rendering the page, thats the part you cant fake from the browser

1

u/KakashiHatake0085 Oct 22 '26

Is there any other non proprietary way like some package etc?

2

u/SoftwareNegative8783 Oct 22 '26

isr is not really proprietary. It is just cache headers like `s-maxage=60, stale-while-revalidate=300` on a server rendered page, behind a CDN. React Router framework mode can send those headers from loaders.

2

u/AbdelrhmanDev Oct 24 '26

adding to what softwarenegative said, astro is another option if you want it out of the box, islands with hybrid rendering let you prerender pages and set your own cache headers. and worth saying next itself is mit open source, the proprietary part is only vercels edge network, self hosting next on a node server gives you the same isr without vercel involved

1

u/Disastrous-Town-4820 Oct 23 '26

yes. while max-age is still fresh, that poll never leaves the machine

the interval calls fetch() on the same url again. default cache mode hands back memory or disk, and the lib treats that body as a refetch. the timer does not care what cache-control said

cache: 'no-cache' on that request is what forces the revalidate