I Setup My Own Personal CDN Using Cloudflare and S3
joel.net
joel.net
Cloudflare implements a dog pile prevention mechanism where if ten simultaneous requests come in for the same page they will make only a single request to the backend, so even just a few seconds of cache time can absorb a huge amount of traffic.
Since my blog rarely updates I use a 15 minute cache time and manually purge the Cloudflare cache when I modify a blog entry. I've survived quite a few high traffic incidents that way.
https://docs.aws.amazon.com/AmazonCloudFront/latest/Develope...
Open bucket is an antipattern here.
What's the best way to utilize a service like Cloudfront or Cloudflare when you need low latency access to static files that aren't getting a lot of traffic? I'd pay more for a service that lets me serve 12kb-10MB files with <50ms latency on Cloudflare edge nodes but some of them are only going to be accessed once a day or less. My understanding is that most of the time these files would just fall out of the edge cache. There'd still be the advantage of going through Cloudflare/Cloudfront's private network but I'm still going to be limited by S3's latency.
It looks like the edge cache max TTL is a month: https://community.cloudflare.com/t/how-long-cloudflare-keeps...
- S3 bucket w/ same name as domain.
- CNAME to bucket
- OR enable static website hosting, CNAME to your bucket's website dns name provided by AWS.
- Done, just make sure CF is proxying not doing pass-thru.
- PS, permissions need to allow public read of your data, of course.
(That being said, there is nothing wrong with Cloudfront. On a recent project we are using all three, cloudfront and cloudflare are not mutually exclusive)