2

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?

1

So i found a workaround for this - i had to add the disable-performance page rule to cloudflare. Now i seem to be correctly getting a HTTP 304 in the browser.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.