Nextjs v.10 getstaticprops "revalidate" stop working on docker container

1.7k views Asked by At

first of all i am not an expert with docker deployment.

The problem i have is that the revalidate feature suddenly stopped working and only work again only if i restart the docker container. For ex. The stock on one of the product did not change.

The webapp built using nextjs v.10 it is e-com webapp and the data came from other webapp which is wordpress that primarily served as data only.

In short, nextjs as frontend deployed on docker container on vultr vps AND wordpress as backend. Revalidate feature work for around 1 month and i need to reproduce or restart the docker container to make revalidate feature work again.

I am not really sure if this problem relate to nextjs or vultr or docker. Could someone suggest a solution or anything? I am really appreciate it if someone can help me with this. Thanks.

2

There are 2 answers

1
Atikur Rabbi On

Static Regeneration (revalidate flag for getStaticProps) need to run NextJs server. As you said in your case it alredy configured and runs for a month. So I think it causes by some error in your nextjs server and it stopped running. Please check the nextjs server logs.

2
tperamaki On

Some code would be helpful, and also logs if there is anything there.

You could start debugging this by adding logging into the start of the getStaticProps. If the log message appears, the invalidate works and gets triggered, but it might fail later on before actually updating the cache.

Please also note that after the reinvalidate timeout the first page request will be the old one, so you would need to refresh the page twice to see the updated information. Also if the getStaticProps fails, the old cached page will be used.

When a request is made to a page that was pre-rendered at build time, it will initially show the cached page.

Any requests to the page after the initial request and before 10 seconds are also cached and instantaneous.

After the 10-second window, the next request will still show the cached (stale) page

Next.js triggers a regeneration of the page in the background.

Once the page has been successfully generated, Next.js will invalidate the cache and show the updated product page. If the background regeneration fails, the old page remains unaltered.

Source: https://nextjs.org/docs/basic-features/data-fetching#incremental-static-regeneration