Next.js Discord

Discord Forum

Refresh old version of the ISR site/component

Unanswered
Wuchang bream posted this in #help-forum
Open in Discord
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?:this_is_fine:

9 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
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
@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
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?