On host I have add this Cache-Control public,s-maxage=5184000,max-age=1200,stale-while-revalidate=300,stale-if-error=300
Ok, everything well. I see that files are caching.
Web server can be accessed only through Cloudflare.
So… Total amount of traffic by Cloudflare and my provider are quite different
Server always send some files. I have tried to compare access.log with cache age and sometimes they are different. Sometimes files that was in access.log not cached. Can you help me? May be I am wrong with this config?
Most static files are cached by default, unless there’s a header coming from origin instructing otherwise.
So you don’t actually need a page rule to make these files cacheable. Also, the Polish and Mirage options can be set at the dashboard’s Speed tab, so they apply to all images on your site.
You can navigate to your domain with developer tools open (F12 on Chrome/Windows) and check each file you think should be cached for a header from Cloudflare:
If the header has MISS or something other than HIT, refresh the page to make it fetch the file again, check the headers again.
If you continue to see files that were supposed to be cached with cf-cache-status: MISS, you can try to add the setting Edge Cache TTL to your page rule, to override any misconfigured caching headers coming from your origin.
Caches in Cloudflare are created at the data centers your site was requested from. So if you live, for instance, in Paris, and you hit the colocation CDG, you may see a header indicating the file is cached. However, if I visit your site from colo=GRU in Brazil, and if your site hasn’t been cached yet there, Cloudflare will request the files again to your origin. So it’s perfectly normal for your website to show pages and files as cached, and yet for your origin to keep receiving CF visits for the same assets.
How can I understand this phrase from here
“If Cloudflare deems a request cacheable, we first examine our caches in multiple network locations for content. If the resource is not present in cache, Cloudflare will make a request to your origin server to fill our cache. The response is then sent to the client who initiated the request.”
I understand that Cloudflare first scan there network for cache and only then go to origin. Or this network is datacenter based and different datacenters don’t interconnect?
From my experience, that sounds like Argo, which uses Tiered Caching. Regular caching is limited to servers in a datacenter. I find that it takes a few visits at a specific data center before I get a HIT every time, like each server (or mini cluster) has its own cache that’s not shared within the datacenter.