So, last week, I had an itch to create a content delivery network (CDN) for my local development environment. I was able to get something working in a few hours; but it looked junky and I've since spent the last few mornings refactoring it into something that feels a little bit more elegant. I present Sticky CDN - a super simple CDN built in ColdFusion.
The concept behind Sticky CDN is simple - you make requests to it (Sticky CDN) and it turns around and makes the same request to the origin server mapped in your configuration file. A single Sticky CDN instance can work with any number of incoming domains and outgoing origin servers.
If Sticky CDN can pull the requested file from the origin server, it caches it locally. On subsequent requests, it then pulls the file from the local cache instead of going back to the origin server. I try my best to adhere to expiration dates defined in the "Expires" and "Cache-Control" headers; but, if I can't find (or parse) those headers, I default to caching the file for 7 days (which can be overridden in the configuration file).
At this point, you're probably wondering why I didn't just use something like Squid or Varnish? Great question. For starters, building something is just more fun, isn't it? Plus, I find that tinkering helps me build a stronger mental model for how these types of things actually work. And, of course, my primary development language is ColdFusion, so having a small CDN built in ColdFusion means a much more effort-free installation process.
Anyway, this is really just for my own personal use; but, I thought I would share.