i have question regarding the cache service of Cloudflare. When I curl a specific asset of my website (a png, css or whatever file)the first time i always get a MISS. Once i run it again i get a HIT on the CF-Cache-Status.
If i try the next day, the same result. Any idea why this happens?
Maybe i should add a Page Rule where Cache Level = Cache Everything, for the directories i have my static files, like www.example.com/img/* ?
This is how caching works. CF saves a request in its cache after it receives it once (per-datacenter) so future requests can be served from cache instead of your server. If that asset isn’t requested often, CF will drop it from its cache so higher-demand assets from other customers can be saved.
Cache everything only changes the file extensions that Cloudflare will cache. In standard mode only these extensions are cached.
You could have a page rule that sets the Edge Cache TTL, however even if you set it as high as you can, CF will evict the cache if the requested resource isn’t requested often and other customers need their resources in cache.
@leonidasfs:
I know what you are asking for and @Judge is right with his explanation.
Like @boynet2 wrote: Cloudflare is no real CDN, its more like a very advanced ReverseProxy Cache.
There are no pull or push zones, there is no guarantee that your Files are caches as long as you set them, or are cached untill they change. This is a reverseproxy Cache, its working on request base, in every datacenter independendly.
To improve your situation, I can show you how I set up my Cache Everything rule and it indeed works better. I’m not sure about if this forces CF to cache the files for 1 month, or (like @Judge said) is just a soft-rule which is no guarantee they will be cached as long as you configurate.
Here is what I set for maximum Cloudflare Cache:
This is the maximum Cache TTL for both atm. I would recommend it to you to have a maximum long lasting Cache in Edge CDN.
This is what I already thought about and I think this makes sense, as soon as you do have high traffic, or do have a commercial website/webshop where everything (static assets) have to be fast at any time!
As “real CDN” mostly cost per 1.000.000 requests which are hitting the real CDN Cloudflare will help you to save some costs if it will be set infornt of your real CDN