I want to know which file extensions are cached by Cloudflare in http proxy.
Images (bmp jpg gif png), graphics (css), scripts (js), etc…
I want to know if also a file zip, rar, exe, are cached by Cloudflare and so my origin served only once. And what is the max size.
MP4 files are also cached if under a certain size, though it’s not in their list of cachable files.
So my server will serve those files only once? And Cloudflare will distribute to clients infinite times (up to cache time)?
So I save a lot of bandwidth?
Well…kind of. Cloudflare doesn’t have infinite cache, and it has a lot of datacenters. Frequently accessed data stays in the cache longer. Standard cache duration is less than a day, I believe. Maybe just a couple of hours. This is great for high-traffic sites. If you’re a low-traffic site, then the load on your server is minimal in the first place.
You can set up some Page Rules to set longer Edge Cache durations, but that file will still get purged sooner if it’s rarely accessed.
Yes and the Cloudflare dashboard will report that to you.
Expanding on this - Google likes to see static resources cached for at least weeks.
I’ll see your expansion, and raise you one. I believe Google is only looking at cache expiration headers, and not Cloudflare HIT/MISS. So if you’ve at least set an extended cache duration, Google will be happy.
Yeah that makes sense. Good note. Golly our work is complicated.
I have a web home server with some zip, rar, and other files. I have 20mbps of upload speed.
If I want to distribute files hosted in my home server to users, I need more than only 20mbps, and so I thought to Cloudflare.
So my server will upload the files only once to Cloudflare proxies, and they will distribute the files to the clients.
This service sounds like a web hosting, because Cloudflare will distribute the files, not my server.
I can increase the cache time, and this is all available in free plan.
Am I right?
Yeah, but not really.
The upload will happen once per POP (currently ~150 of them, not all accessible on the free plan, though) and every time it’s evicted from cache, the first time someone requests it at that POP.
You can increase the cache time, but it’s not a guarantee that it is going to be guaranteed, depending on the access frequency by users.
It’s sort of the opposite. Clients will request a file from Cloudflare. Cloudflare will go get it from your server. Cloudflare serves the file to the client, and saves a copy in it’s cache for the next client. On a per-POP basis.
I suppose if you’re handy with programming you could use Cloudflare worker and serve files via 3rd party storage like Amazon S3 bucket or DigitalOcean Spaces https://developers.cloudflare.com/workers/recipes/static-site/
I have available a shared web hosting where I can collect files to distribute, also not in my home server, so I don’t have problems.
Can I decide file extensions and cache time?
Yes you can create rules to cache by file extension.
Is it possible in free plan? And how?
Yes it’s possible in the free plan. Free plans give you three page rules.
How? Well, I’d rather teach you to fish (or build a fire):
I tried this:
And I didn’t yet activate the http proxy for that DNS.
When I will activate the proxy (orange cloud) this rule will take effect.
All requested from that DNS will be catched in Cloudflare POP for 1 month and in clients’ browsers for 1 day.
Am I right?
Yes, correct. That means Cloudflare will try to cache any content for 1 month, while it will tell client browsers to cache it for 1 day.
That will cache everything, including every html page. Are you sure that’s what you want?
I created that DNS only for images hosting.
How can I decide max file size for catching?