Netlify serving stale content


I have hosted the website called [NextJS] in Netlify
Unfortunately its serving previous build’s stale content or build files.

Here are the request id for the stale site.

x-nf-request-id: 01G108T6FZ4DG9N2E28PDS29DC
x-nf-request-id: 01G1090AYAC3BGJQ17XEM63X60

Now when i add a query parameter
Titus and Roshin's Wedding Website
It serves the correct content
( Request id for the same )
x-nf-request-id: 01G109355396V8Q35J6XCCMQC9

What shall i do from my end , to so that after each build , rightful pages & build files are served correctly without hampering the users ??

CC : @fool @luke

Is it an issue from my end or from your end ?

Hoping to hear from you at the earliest :slight_smile:


RE : Email Update as suggested by @luke

Luke Lawson (Netlify)

Apr 19, 2022, 1:57 AM EDT

Hi Titus,

You are overriding our fine-grained cache invalidation by modifying the cache-control headers. You can see the cache control header being sent below:

$ curl --compressed -svo /dev/null  2>&1 | egrep -i 'cache-control'< cache-control: public,max-age=31560000,immutable

That header above tells our CDN to cache the URL for a year.

If you do not want our CDN to cache the content for longer than the time the deploy is active, you must use our default cache-control . When you change the default headers you change the behavior of our CDN for your site.

There is a blog post about how we cache at Netlify written by one of our founders here:

If you use the cache-control: public, max-age=0, must-revalidate header, then the content will be correctly purged when new deploys occur.

So you are suggesting i shouldnt keep a cache header for a year ? & i should keep the header as
cache-control: public, max-age=0, must-revalidate

But I was under the assumption that Build deploy would completely wipe off /invalidate the CDN Cache for the domain even if there is a Cache Header present. Is my assumption correct or should i add the aforementioned header ?

I have updated the cache header & re-deployed the same.

curl --compressed -svo /dev/null  2>&1 | egrep -i 'cache-control'

< cache-control: public,max-age=0,must-revalidate

Could you please purge the cache now ?

[ still getting the stale content : x-nf-request-id: 01G10JW2MNBKMDR2CRGF7GX2NM ] {FYI}

I am still getting stale content

x-nf-request-id: 01G118CYAJV8WT8YBSHEXYKPJX

Could someone please purge the CDN cache ??

Hi @titusrk
Just to check, once you had reverted the sites header to Netlify’s default did you deploy with a clean cache as depicted here:

If you have already attempted this I’m happy to flag this up to a support engineer.

Hi, @titusrk. I have purged the cache for this site now. About this:

That is an incorrect assumption. That is the opposite of what the content-control: header documentation says the header should do. That documentation says there is no way to purge content from the cache if you use those headers to enable caching. It is also the opposite of what I said here:

and here:

Changing the header breaks the cache invalidation. The cache invalidation only works with the default headers. If you modify the cache-control headers the new header will modify the caching for any and all URLs that use the modified header.

The site content has been purged now. If you are still seeing out of date content, please let us know which URL is affected and the x-nf-request-id of the specific response is always helpful.