Refresh old version of the ISR site/component
Unanswered
Wuchang bream posted this in #help-forum
Wuchang breamOP
When I have my data updated with ISR and site is somehow cached with old data in the browser, I dont see new data until clicking F5, even when it was loaded hours ago. Is there a good way to load fresh data?

50 Replies
@Wuchang bream When I have my data updated with ISR and site is somehow cached with old data in the browser, I dont see new data until clicking F5, even when it was loaded hours ago. Is there a good way to load fresh data?<:this_is_fine:770004314634321971>
It’s pretty normal, that your browser cache the page contents. Technically the browser decides how long stuff will be cached. However, even when the cache is 100% invalid/stale it does not automatically trigger a refresh or a request to your server to get fresh data. That’s how browsers work. Then only thing that comes to my mind is having some cron job to get a new version and then having on a client an interval to refresh the browser. That’s not a good practice, but it would work technically
@B33fb0n3 It’s pretty normal, that your browser cache the page contents. Technically the browser decides how long stuff will be cached. However, even when the cache is 100% invalid/stale it does *not* automatically trigger a refresh or a request to your server to get fresh data. That’s how browsers work. Then only thing that comes to my mind is having some cron job to get a new version and then having on a client an interval to refresh the browser. That’s not a good practice, but it would work technically
Wuchang breamOP
maybe when user has old data theres possibility to refresh the page?
How do you know if the page has been updated without an additional request?
I guess then you need something like a websocket or similar, but that’s also not ideal
I guess then you need something like a websocket or similar, but that’s also not ideal
@B33fb0n3 How do you know if the page has been updated without an additional request?
I guess then you need something like a websocket or similar, but that’s also not ideal
Wuchang breamOP
something on page open, if data is older than 1 day, force refresh for example
because you dont need to have page opened in the tab for it to happen
@Wuchang bream something on page open, if data is older than 1 day, force refresh for example
Then you can do ISR. After a specific amount of time the page automatically revalidates and then it’s a new static version of the page. But keep in mind, that you get this new static version only when you refresh the page
@B33fb0n3 Then you can do ISR. After a specific amount of time the page automatically revalidates and then it’s a new static version of the page. But keep in mind, that you get this new static version only when you refresh the page
Wuchang breamOP
i have isr already, but it doesnt get a new page until f5
and i should somehow store the page generation cache in the browser
its intended, that you cant see it instantly with ISR. Its like this:
1. First request after revalidation -> stale-while-revalidate -> serve old content
2. Second request after revalidation -> server new content
Which next version are you using?
1. First request after revalidation -> stale-while-revalidate -> serve old content
2. Second request after revalidation -> server new content
Which next version are you using?
@B33fb0n3 its intended, that you cant see it instantly with ISR. Its like this:
1. First request after revalidation -> stale-while-revalidate -> serve old content
2. Second request after revalidation -> server new content
Which next version are you using?
Wuchang breamOP
instantly is not an issue for me, but if you see data that was revalidated couple days ago then its bad
it should revalidate all new page opens
i use latest next.js 15, will hop on 16 soon
@B33fb0n3 its intended, that you cant see it instantly with ISR. Its like this:
1. First request after revalidation -> stale-while-revalidate -> serve old content
2. Second request after revalidation -> server new content
Which next version are you using?
Wuchang breamOP
yea, but new page open after many days can show you old data, that was already revalidated and loaded many days ago by a different user
yea, when using next15, you need to create a dynamic page then. With next16 every page is dynamic and you can have a static shell inside of it. Then give your page a revalidation time of X (for example 'hours') and then use iirc
updateTag to revalidate and get new data instantly@Wuchang bream solved?
@B33fb0n3 yea, when using next15, you need to create a dynamic page then. With next16 every page is dynamic and you can have a static shell inside of it. Then give your page a revalidation time of X (for example 'hours') and then use iirc `updateTag` to revalidate *and* get new data instantly
Wuchang breamOP
i dont understand
where can i see the difference in isr behaviour and this updateTag?
@Wuchang bream where can i see the difference in isr behaviour and this updateTag?
you can find them inside the docs: https://nextjs.org/docs/app/api-reference/functions/updateTag
In your case you can use next16 and then add a revalidation time of X and then it will refresh instantly with updateTag instead of showing the stale data. Effectively you skip "1." from https://nextjs-forum.com/post/1443229807516192799#message-1444310293730689024
In your case you can use next16 and then add a revalidation time of X and then it will refresh instantly with updateTag instead of showing the stale data. Effectively you skip "1." from https://nextjs-forum.com/post/1443229807516192799#message-1444310293730689024
@B33fb0n3 you can find them inside the docs: https://nextjs.org/docs/app/api-reference/functions/updateTag
In your case you can use next16 and then add a revalidation time of X and then it will refresh instantly with updateTag instead of showing the stale data. Effectively you skip "1." from https://discord.com/channels/752553802359505017/1443229807516192799/1444310293730689024
Wuchang breamOP
so the isr works properly on next16? or more like cached ssr
@Wuchang bream so the isr works properly on next16? or more like cached ssr
instead of using ISR, use next16 and its caching possibilities (like mentioned the updateTag) or stay with a dynamic page. More on the caching stuff is available here: https://nextjs.org/docs/app/getting-started/caching-and-revalidating
... and the UI immediately shows the change, rather than stale data.
@B33fb0n3 instead of using ISR, use next16 and its caching possibilities (like mentioned the updateTag) or stay with a dynamic page. More on the caching stuff is available here: https://nextjs.org/docs/app/getting-started/caching-and-revalidating
> ... and the UI immediately shows the change, rather than stale data.
Wuchang breamOP
so performance and load times will be worse?
@Wuchang bream so performance and load times will be worse?
In next16 the performance is actually better. But you have longer build times on self hosted platforms like coolify, docker or others. On vercel the build times are faster
@B33fb0n3 In next16 the performance is actually better. But you have longer build times on self hosted platforms like coolify, docker or others. On vercel the build times are faster
Wuchang breamOP
ill take a look thanks, so updateTag i only need when manually updating and revalidation should work without the issue from this thread?
@Wuchang bream ill take a look thanks, so updateTag i only need when manually updating and revalidation should work without the issue from this thread?
it should work like expected then, we doing that, yea
@Wuchang bream solved?
@B33fb0n3 <@1086355945120092190> solved?
Wuchang breamOP
if it will work and it needs to be marked as solved, yes
i would test it some day
i would test it some day
so basically i dont need any extra changes in the code and it will work right?
regarding the revalidation
@Wuchang bream so basically i dont need any extra changes in the code and it will work right?
You need to at least switch to next16 and remove the ISR stuff. Then build a static shell and the action and then you are done 👍
@Wuchang bream static shell?
Yea, that’s how next16 works
@B33fb0n3 Yea, that’s how next16 works
Wuchang breamOP
didnt find anything about that
there
https://nextjs.org/docs/app/guides/upgrading/version-16#upgrading-from-15-to-16
there
https://nextjs.org/docs/app/guides/upgrading/version-16#upgrading-from-15-to-16
@B33fb0n3 its here: https://nextjs.org/docs/app/getting-started/cache-components
Wuchang breamOP
and the component becomes static again after it was loaded and refreshesd?
1 user sees old data: component/site gets refreshed
2 users enters 30 seconds later, does he have the same pattern of seeing/loading old data and refreshing again, or does he have fast static page again?
1 user sees old data: component/site gets refreshed
2 users enters 30 seconds later, does he have the same pattern of seeing/loading old data and refreshing again, or does he have fast static page again?
No, the second user will have an instant response with the new data (if it was invalidated in the meantime with updateTag by the user)
@B33fb0n3 No, the second user will have an instant response with the new data (if it was invalidated in the meantime with updateTag by the user)
Wuchang breamOP
so updateTag sends information to the other user?
@Wuchang bream so updateTag sends information to the other user?
when it comes to live updates to different users, then its a whole different story. Then you need a server somewhere. Both users should be connected to it and then they can exchange messages e.g. data. You can use polling with websockets or long and short polling
@B33fb0n3 when it comes to live updates to different users, then its a whole different story. Then you need a server somewhere. Both users should be connected to it and then they can exchange messages e.g. data. You can use polling with websockets or long and short polling
Wuchang breamOP
updateTag sounds like it
i host my site on the server
nah, updateTag does not update the content instantly on the other user open website. The user need to refresh his tab and then you are right: then he would instantly see the change
Wuchang breamOP
oh nice
how is that faster than ISR?
@Wuchang bream how is that faster than ISR?
its next16 that makes it fast. UpdateTag was introduced in next16 und ISR exists before next16
Wuchang breamOP
were there any changes to bundle size? uncompressed is like 300 400kb
Wuchang breamOP
compressed next and react were around 100kb, css splitting is experimental?
@B33fb0n3 its next16 that makes it fast. UpdateTag was introduced in next16 und ISR exists before next16
Wuchang breamOP
the same code with ISR on next 16 will still be broken right?
Wuchang breamOP
was the performance benchmarked? i think i had 92 score on pagespeed and now i have 90
Kars
Visa are available
To any country of your choice
Wuchang breamOP
!report