A 301 response with Cache-Control: no-cache gets cached when Browser Cache Expiration is set

There’s an endpoint in one of our web sites that dynamically returns a response depending on the Accept header value. It returns a normal 200 response when the header value includes a supported MIME type, or a 301 response that points to another endpoint otherwise. All these responses are returned with Cache-Control: no-cache because Cloudflare does not offer support for Vary: Accept and therefore any response from the endpoint should not be cached.

However, Cloudflare caches a 301 response and serves it with Cache-Control: private, max-age=14400, where I think 14400 is from the “Browser Cache Expiration” setting which in our case is 4 hours.

Is this intended behavior or a bug?

Hi @akinori,

This is the intended behavior whenever the TTL specified by the origin is lesser than the TTL you set in Browser Cache Expiration. You can avoid this by setting the Browser Cache Expiration to Respect Existing Headers:

https://support.cloudflare.com/hc/en-us/articles/200169266-Does-Cloudflare-honor-my-Expires-and-Cache-Control-headers-for-static-content-

This topic was automatically closed after 30 days. New replies are no longer allowed.