304 Status


#1

I have just been able to get a site pointing to Cloudflare and was wondering if you see any issues with the Response Headers I am pulling from Chrome Developer Tools.
Mainly the Status 304 and the cf-cache-status:REVALIDATED

Request Method:GET
Status Code:200 (from memory cache)

Referrer Policy:no-referrer-when-downgrade
Response Headers
accept-ranges:bytes
cache-control:public, max-age=14400
cf-cache-status:REVALIDATED
cf-ray:3c3c5aed49402216-EWR
content-length:468
content-type:image/png
date:Sun, 26 Nov 2017 11:02:23 GMT
etag:“1d4-5116f94c483ce”
expires:Sun, 26 Nov 2017 15:02:23 GMT
last-modified:Mon, 16 Mar 2015 22:43:38 GMT
server:cloudflare-nginx
status:304
vary:Accept-Encoding


#2

If nobody else replies, this all looks ok to me.

A 304 looks to agree with the REVALIDATED status. Cloudflare’s internal cache expired, so it checked your server and found the file hadn’t changed.


#3

Thanks for the reply…
What causes their internal Cache to Expire?

How can I tell if the images/css ect… is actually being cached on Cloudflare’s end?

Can you explain or do you have any documentation as to when I would see a 200 instead of 304 and a HIT instead of Revalidated?


#4

There are two caches we’re talking about:

  1. Cloudflare Edge Cache: Your static files held on Cloudflare’s edge servers for a certain amount of time.
    https://support.cloudflare.com/hc/en-us/articles/202775670-How-Do-I-Tell-Cloudflare-What-to-Cache-

  2. Browser Cache: The content your visitors’ browsers naturally hold onto according to your cache headers.
    https://support.cloudflare.com/hc/en-us/articles/200168276-What-does-the-Browser-Cache-Expiration-do-

I’m no cache expert, but I believe this is how it’s working: Since Cloudflare acts like a browser visiting your site, Cloudlfare edge-caches images, css, etc. for a couple of hours. But it knows you have your browser cache header set for a day or whatever. So after Cloudflare’s edge cache expires, but its browser cache hasn’t expired, it needs to refresh the edge cache by seeing if your file has changed on your server. No change means it gets a 304 and the Edge Cache is REVALIDATED for another couple of hours or so.

It’s possible the browser cache setting has nothing to do with this, but the edge cache checks back after it expires to see if the file has changed since the last edge cache fetch.