Cloudflare keep to Revalidated my static files even my origin tell to keep a half-year

I found that many path got Revalidated very frequently and lead to high load on my origin server. I want Cloudflare to cache this files as most as possible but this keep revalidate all day. I'm on enterprise plan and support center tell me to try purge that path then that work fine, after that every request for this path got HIT. That's mean I need to purge all of path which faced this problems. I want solid solution to fix this problem, Could you please suggest the correct way rather than purge all of path? (Because this very expensive for large domain.)
No description
11 Replies
Non
NonOP3w ago
Here's my response header from Cloudflare
< content-type: image/jpeg
< content-length: 18371
< cache-control: public, max-age=16070400
< cf-bgj: imgq:85,h2pri
< cf-polished: degrade=85, origSize=25526, status=webp_bigger
< etag: "0812e4c25661939fd5d5d4b32ee3c43fd0b53ee6"
< expires: Sat, 18 Oct 2025 10:24:19 GMT
< x-cache-status: MISS
< cf-cache-status: REVALIDATED
< accept-ranges: bytes
< strict-transport-security: max-age=2592000
< x-content-type-options: nosniff
< server: cloudflare
< content-type: image/jpeg
< content-length: 18371
< cache-control: public, max-age=16070400
< cf-bgj: imgq:85,h2pri
< cf-polished: degrade=85, origSize=25526, status=webp_bigger
< etag: "0812e4c25661939fd5d5d4b32ee3c43fd0b53ee6"
< expires: Sat, 18 Oct 2025 10:24:19 GMT
< x-cache-status: MISS
< cf-cache-status: REVALIDATED
< accept-ranges: bytes
< strict-transport-security: max-age=2592000
< x-content-type-options: nosniff
< server: cloudflare
and some request got HIT, I don't know why this happen.
Non
NonOP3w ago
Here's page rule for this domain.
No description
Non
NonOP3w ago
fyi; For this domain I want Cloudflare to cache everything forever.
Zack0322
Zack03222w ago
Cloudflare Docs
Cache by status code · Cloudflare Cache (CDN) docs
Customers can set cache time-to-live (TTL) based on the response status from the origin web server. Cache TTL refers to the duration of a resource in the Cloudflare network before being marked as STALE or discarded from cache. Status codes are returned by a resource's origin.
Zack0322
Zack03222w ago
basically you need to update the TTL for your 300-599 range to exclude 304 otherwise once the asset is revalidated the first time, the ttl of the asset will become no-cache (i.e always revalidate) instead of whatever ttl you set for hte 200
Non
NonOP2w ago
So, that mean If I remove response header etag out. Client will not try to revalidate it and Cloudflare will never revalidate asset with my origin server right?
Zack0322
Zack03222w ago
you don't want to do that. you should update the rule that sets 300-599: no cache to: 300-303: no cache and 305-599: no-cache this way the 304 status code will inherit the ttl of the 200 which you have as "forever"
Non
NonOP2w ago
Wow, I think we found the root cause. Here's my current config
No description
Non
NonOP2w ago
I need to change my setting to like this?
No description
Non
NonOP2w ago
Thank you so much, I will try to confirm this on production by next week.
Zack0322
Zack03222w ago
that's correct

Did you find this page helpful?