Netlify ignores cache-control for 304

The default cache-control header has a heavily negative impact on my web app. Content is generated dynamically as you navigate through the app. Images are constantly being reused but without cache they involve a delay which is clearly noticeable.

This slows down navigation a lot and is not acceptable. But it should be ok because you can change the header. So I set this netlify.toml:

  for = "*"
    cache-control = "public, max-age=600"

That works like a charm for a while. But after a few minutes Netlify goes back to serving the default header and the annoying experience comes back with it.

Why? How can we solve this?

After a lot of testing I finally found the reason.

Netlify ignores the cache-control header configuration for 304 responses (etag matches) and ALWAYS sends the default one. This is extremely annoying since I already distributed the link though Netlify and it makes the apps look a lot slower…

I need some kind of solution please

Hi Luis,

We’re still working on this case in the helpdesk with you and the team will be able to reconsider your results next week when we have some bandwidth. We’ll follow up in community too once we come to some conclusion.

@luiscastro193, I’ve followed up with in our helpdesk ticket. It looks like our system parses custom headers in a case sensitive way. As a workaround, I have suggested defining the header like so:

Cache-Control = "public, max-age=600"

Can you confirm if this works for you?

It doesn’t:

As always 200 responses are fine but 304 responses go back to the default Cache-Control.

This is the config file:

Ah ok. It looks like a new issue then. I’ll get that filed as well and will update here if and when we get a fix deployed. Unfortunately, I don’t have a workaround for it at this time.