Netlify ignores cache-control for 304

Hey @jasikpark,

I’m not following what you’re trying. By looking at the toml file, it appears as if you’re trying to set a custom header only when the file is served with a 304 status. Not only this won’t work (as it’s not currently supported), I’m not sure what this will solve.

Could you elaborate?

This is trying to work around a bug in Netlify. According to RFC 7232 The 304 response “MUST generate any of the following header fields that would have been sent in a 200 (OK) response to the same request: Cache-Control, Content-Location, Date, ETag, Expires, and Vary.” Netlify doesn’t do this so @jasikpark is attempting to hack around this by setting the Cache-Control header manually.

Oh well, in that case, like I’ve said above, it’s not currently supported and thus would not work.

It doesn’t make sense to support it either because the RFC says what headers should be present and that they should match the values from the 200 response. Configuring the headers differently is invalid. But it would be nice to get this bug fixed.

Has there been any movement on this?

I have a similar use case where I’d like to control the caching. Initial request works fine, but it seems the etag is used in requests after a refresh and then I get stuck in a 304 loop.

I’m sure this might be mentioned above and you would have gone through it, but this is a risky endeavour:

In any case, the issue still persists, and you can probably work around it by using a service worker to cache files.