1/ On cloudflare, they say (in their terms) they don’t allow caching websites which are mainly photos or videos.
I’m looking for a CDN that i can put in front of an S3-compatible bucket. This CDN would take all of the replication, and moving the data where it’s the most requested (mainly images and videos). I’ve heard imgur use Cloudflare to cache all their images. I would be curious to know how they do this.
I don’t mind about paying cloudflare bandwidth for handling request. It just not clear that it’s allowed or not. Maybe in the entreprise plan?
2/ Also, R2 has a really confusing pricing model. Can i use R2 to serve image/video? What is the cost per TB of bandwidth?
“There are no charges for egress bandwidth.” and read request is 0.36$/million req.
So if i request 1 million image , i pay 0.36 ? . And if i request 1 million time a video, do i also pay 0.36$. So i would pay the same price? how does that make?
3/ On amazon, there is S3 and Cloudfront. It seems absurd to me that Cloudflare is a cdn, have a S3-compatible service (R2) but doesn’t allow to cache your R2 bucket the same way S3 and Cloudfront do.
Cloudflare is just a pull-CDN, you can use some options like Smart Tiered Caching (free) to have it cache the content in a single upper-tier Cloudflare pop (point of presence )near your origin, so you have local pop, check cache, if not in, reach out to upper-tier pop, then origin, but the thing you are looking for is more like a push CDN (which would replicate data) then a pull CDN.
Yes, Enterprise agreements would let you bypass the normal self-serve policy restricting content, I believe they always pay for bandwidth used as well, which lets them do this.
Yes
None, just the normal class b/read request charge
Yes, except videos are usually a lot of range requests. You wouldn’t want someone to need to download an entire 500 MB video fully before loading. But fundamentally yes, it’s the same cost regardless of the side of the object, per request.
R2 is Cloudflare’s own service, which is exempt from the normal CDN Terms:
Finally, we made it clear that customers can serve video and other large files using the CDN so long as that content is hosted by a Cloudflare service like Stream, Images, or R2.
That’s an awesome news for R2. So i can connect my r2 bucket to my subdomain like img.mydomain.com and set it to cache (orange cloud icon)?
So then the image/video/files will automatically be replicated where it’s the most requested by cloudflare CDN and i would pay the normal r2 rate whether a file is being pull from the CDN or R2 storage ?
Yes, you should make a cache rule as well to force cache for all extensions.
There’s no replication, neither with R2 nor the Cache. Your R2 Bucket gets created in a location (by default, closest to you), and cache is per colo (Cloudflare Datacenter). For example, if you’re near Chicago, you’ll likely hit ORD (Chicago Pop), it would check local cache for that object, if it’s a cache miss, it will fetch from your bucket, which only exists in a single region, and then return that response, and cache it in that specific colo.
It’s likely to stay in cache for longer the more it is being requested, but the object itself will never be moved.
I talked above about Tiered Caching, please note that does not work with R2 Custom Domains. You just have the simple per-colo cache.
Custom Domains are just a simple Class B /GetObject, unless the object is cached, then it’s not an R2 operation.