I didn’t find any answers to this question after looking at CF documentation, this forum, and googling into CF, so I’m starting a new topic regarding the meaning of the Age header CF sends back with cache hits. The http caching specification leaves enough ambiguity that I think it makes sense to ask about what happens in the wild and not assume there’s one way to match the specification.
Background:
I’m on an Enterprise plan.
Using Origin Cache Control page rule
Question:
What determines the value of the Age response header? Is “The time since the resourced was cached” is too reductive an answer because it ignores whether the content was revalidated or changed?
Two cases to consider:
Case A: Content is cached at a URL for a 60-second time-to-live and then is revalidated with byte-for-byte same content 10 seconds later. If the resource is accessed 20 seconds still later, is the Age header going to be 90 or 30?
Case B: Content is cached at a URL for a 60-second time-to-live and then is revalidated with slightly different content 10 seconds later. If the resource is accessed 20 seconds still later, is the Age header going to be 90 or 30?
Any help by those with experience in this area is much appreciated
It is the time the object has been in cache (or for revalidated objects the time since the expired object was revalidated based on a request for the object).
It sounds like for case A and B the answer should be 30 if I interpret your reply correctly.
I am seeing too-large Age header values in responses on URLs where I think I’m setting s-maxage=45. I think for some reason CF is setting the max age to four hours. I’ve seen values as high as 7000 seconds. I can’t nail down the steps to reproduce it though
Content won’t be revalidated until it expires so a an object cached at 30 seconds wouldn’t be revalidated for at least that.
Are you setting both a cache max-age and s-max-age by chance? The latter would be honored by the CDN and not exposed to a client query and is usually longer than the former. Beyond that I believe 4 hours is the default cache length without an explicit cache control header for an asset, so I would try a curl direct to origin to see what is set.
@OliverGrant, I am setting s-maxage=45,private=Set-Cookie when responding from the origin to cloudflare, and then in a cloudflare worker I’m replacing the cache-control header with one for browsers to see which is private, no-cache.