Netlify.toml proxy/redirect and CDN cache

Hello there.
I have a very specific situation, and couldn’t find a similar post/issue on the forum.

My site (https://impulsoteam.netlify.app/) has a proxy redirect configured to one of its paths:
/lider-de-alto-impacto/ → https://lideranca.impulso.team/

https://lideranca.impulso.team/ is hosted in another service.

The problem that i’ve noticed is that once the target is updated, the proxy path shows the old content
If you access the target domain directly, it show the correct content.
For instance, if you access this deploy preview, witch has the proxy enabled (Líder de Alto Impacto | Como tomar melhores decisões ), it shows one version of the content. If you go directly to the target domain (Líder de Alto Impacto | Como tomar melhores decisões), it shows the updated (if only one “-” between text blocks, because it’s production :slight_smile: )

Any help i can get to demystify this behavior is welcome

Thanks :smiley:

@brosig I appear to be seeing the same response in both locations, which you would expect as I’ve never visited either before.

What you’re most likely seeing is your browser’s cached version of the page.

The response headers on the Netlify proxied one appear the same, albeit they have clearly been modified to lowercase etc.

In both cases I see the cache-control header that’s set by the other service:

Cache-Control: s-maxage=31536000, stale-while-revalidate

Hi, @brosig. The CDN caching is happening because the site you proxy to is sending this header (and thank you, @nathanmartin, for pointing it out first):

cache-control: s-maxage=31536000, stale-while-revalidate

The site you are proxying to is saying “cache this for as long as 31536000 seconds (365 days)” when it sends that header. The CDN then does exactly this.

So, why is our CDN caching that proxied URL? The answer is because you told it to do so.

If you don’t want those URLs to be cached, then the solution is:

  • stop sending the header saying to cache it

If there are other questions about this, please reply here anytime.