Invalid/old content served by netlify using serverless nextjs app

Hello,
we’re using the following setup:
nextjs application deployed as serverless using github actions and netlify cli (including netlify/plugin-nextjs). This page uses static rendering using getStaticProps and getStaticPaths and ISR with a revalidate prop set to 10 (so it also exports some functions).

The problem now is, that everything is totally fine on the preview page when deploying, but the production deployment often gets served old content from days ago. It’s the HTML that is outdated with links to hashed css files that don’t exist anymore. When using different browsers on the same machine one might encouter 4-5 different versions of the same resource served to you.

I’m totally unsure how this happens and what could cause these old caches from being served.

Here are some sample requests to the same resource using different browsers, just seconds apart. There was no deploy in between.

I’m thankful for any advice you can give me to nail this problem down.

Hi @martin.juhasz,

The URL fro the image doesn’t seem to exist anymore for us to be able to test. Has something changed?

Hey, that url should not be visible. You can give it a try here: https://test-reboot-staging-5.netlify.app/test/martin

Are these the files your HTML is referencing to that are no longer in the latest deploy?

image

no, its about something different. this is just a WIP currently and related to next.

I’m talking that the html file itself alters its contents (watch the numbers in the big headline) or check the date in the header of the response.

I’m not sure I’m seeing the error. The date in the header seems correct to me. Do you have a request ID header from a problematic page? We can check that further.

sure, currently on our main site one resource should serve an html page with f.e x-nf-request-id: 01F9XN5HJWN364HTJ5A73875TN which is displayed correctly.

But i can also get the following versions when requesting said resource which are outdated:
x-nf-request-id: 01F9XN4B6X0N7VRFDZQZDTP7VN

Hey there, @martin.juhasz :wave:

Thanks for sharing the above details. We have taken this to our Nextjs team and they have a few questions that will help us dive into this further.

  1. Are you using fallback on your site? If you can confirm this, it will help us make some further connections here.
  2. Do you have a public repo that you can share with us for this?

Thank you!

Hi @martin.juhasz :wave:

We have rolled out a fix for this issue and it should now be resolved. Please let us know if you have any further questions.

Thanks,
Hillary

Hello all:

I am having a similar issue. I have a page with revalidate=60 (a minute) but it does not get regenerated. It actually gets generated as static during build, and never again. What am I doing wrong.

This is our site
Welcome to explore! (main–sembo-inspire-explore.netlify.app)

This is a build
Deploy details | sembo-inspire-explore (netlify.com).

A request id: 01GRXGB36FCH1DHM7W6YM1F484

And the return excerpt from getStaticProps:

        return {
            props: {
                trips,
                healthz
            },
            revalidate: 60,
        };

Thanks

Hello:

I, almost just, now realized it works as expected in other pages that are not in pages/ root. Is that intentional?

Thanks a lot

Hi @esg,

When I tried your website now, I seem to get a revalidated response as expected. Why do you think it’s not being revalidated?

Hello @hrishikesh

Thanks for reaching back.

I still do get the problem. If you go to my site, you will see a JSON text with server time. If you go to project root that time is “02/10/2023 16:02:10”, which is the latest release time. That seems to me it was statically generated during deploy, and build logs match that. If instead you go to healthz instead, it does display current time, or close to because revalidate is a min.

Both pages, root and healthz have the same values, almost identical code. It works on healthz does not on /

Thanks again for helping

Hello again @hrishikesh . I now see my / (root) updated. Perhaps I have been looking at the stale version all along. I will try to collect a little more info and get back to you.

@esg Thank you! Best of luck.

Hello @hrishikesh

I think I know what happened. Could you please tell me if it makes sense?

We have a rather flaky backend and this getStaticProps is still not retrying. I realized the error handling was not setting the revalidate property. So I guess netlify used SSG instead of ISR, so I could expect no expiration nor regeneration.

If that’s the case, what makes more sense, after retries are in place but still fails, to return an error?

Thanks a lot

Yes, if you don’t send a revalidate value, it would be cached till the next deploy.

I’d suggest to make sure you always return a revalidate value, whether an error or not.