I'm using Cloudflare to cache certain APIs. I'm setting the below headers in my Origin server:
Cache-Control: public, must-revalidate, max-age=300
Basically, I'm instructing the browser here to cache the response for 5 minutes. Along with these headers I also send an etag across.
After 5 minutes , I get the latest request and check its Etag headers. If they match, my origin server sends back an HTTP 304.
But Cloudflare isn’t proxying back an HTTP 304 but an HTTP 200 back to the browser making the browser download the response again despite there being no change.
These are the response headers I get back from Cloudflare:
cache-control: public, must-revalidate, max-age=300 cf-cache-status: REVALIDATED server: cloudflare status: 200 vary: Accept-Encoding
But I can see from my server logs that there is an HTTP 304 sent back. Why is CF still sending an HTTP 200 to my browser. Is there something I need to modify in my cache headers?