Camilo
Camilo

Reputation: 7184

Next.js Incremental Static Regeneration not reflecting changes without reloading the page

Trying to implement Incremental Static Regeneration on a Next.js project.

There is an index page with a list of posts using revalidate: 1 on getStaticProps().

On a different page, there is a form used to edit the post title. This pages makes an AJAX call to an API endpoint that updates the record on the database.

After editing a post title, I go back to the page with the posts list, using next/link, but the list shows outdated data. If I reload the page I still see outdated data, but as soon as I click the link to the posts list page again, the data is updated.

Am I missing something or this is the expected behaviour?

Here is a repo replicating this scenario (uses "product" instead of "post"):

Upvotes: 2

Views: 1350

Answers (1)

tmwilliamlin168
tmwilliamlin168

Reputation: 571

This appears to be expected behavior (https://youtu.be/yGuN_9rng6o?t=806). On a new request (when you reload), Next.js will first serve the old page but start generating the new page so that the next request will be updated.

Upvotes: 2

Related Questions