Inside a Box

This blog is currently hosted on a public Cloudflare R2 bucket. With the overwhelming number of hosting options I chose this because: domains are cheap, hosting is (hopefully) free, and I haven't used Cloudflare before. Why R2 over Pages? It just seemed simpler: use any S3 compatible tool to upload files and don't mess around with wrangler or connecting to GitHub.

It is perhaps a bit embarrassing to say, but it took me too long to figure out how different origins are added to a Cloudflare cache. I kept reading the Cloudflare Cache documentation, seeing references to origin but not seeing anything describing how they are actually configured. It's quite simple, really, you just set the Proxy status attribute of a DNS record to "Proxied".

My mental model for how a CDN works and is configured was built by using AWS CloudFront. In that model, you create a distribution (cache) and attach different origins and route to them using various request attributes like method or path. You can use the generated cloudfront.net domain name or add a CNAME or alias record to a domain you manage.

The general concepts are all the same on Cloudflare, but it's presented differently. You don't create a distribution, you create a website (a domain managed by Cloudflare). Origins are added by these special proxied DNS records. There are some quirks. For example, R2 buckets are made public through a special "R2" record type; but those can only be created from the R2 page.

The Cloudflare approach is simple and straight forward, but I couldn't see past my preconceived notions of how it would work. This is a lesson we all seemed to be doomed to learn over and over again: our assumptions betray us and we need to approach new things with an open mind. Maybe some day that lesson will sink in. Until then, I'll be kicking myself each and every time.