A Weekend With Caddy

-Ben

I’ve been dabbling with Caddy web server. It’s the easiest reverse proxy I’ve found for self signed development certs. I set up a Caddy server to run my personal blog, a static website. This weekend, I took it a step further and used some caddy templating to make a mostly static site dynamic. The outcome? Every single one of these projects has felt like a magical experience. In this post, I focus on this past weekend when I used some caddy templating to make a mostly static site dynamic.

I host a countdown timer for various friends and family’s weddings. Previously, it was an entirely static site I made for my own wedding, hosted on Github Pages. Then I changed it for the next wedding. But then I couldn’t see how long I had been married for!

I needed the barest amount of dynamic content on my page. I didn’t want to ship everybody’s wedding dates to the client, so it needed to happen server side. I make web apps (React, et al) for a living but that was just way too much (effort, code, time, etc) for what should be a simple problem, one interpolated date!

I had been testing Caddy to host my personal blog, a static website. It’s been performing phenomenally, I’m able to deploy faster to it (via rsync) than to SourceHut Pages most of the time. I had recently come across the Caddy templates module. For my blog, I was resistant to becoming too dependent on a feature like that, in case I needed to switch servers or something. But the concept was the exact right amount of complexity for my wedding countdown timer project.

It took me a few hours to adapt my static site: loading a json file server side then interpolating the date into my timer-element web component and deploying the changes on my public facing web server (adapting the Caddyfile I had there to host two sites at the same time!). But the end result? I’m very impressed! I was able to add a bunch more weddings to my site by adding lines to the json file. Everyone I texted about it was happy to see the counters to their weddings! It will last as long as Caddy does, I didn’t need to introduce or maintain any other moving parts.

For the future, I’m exploring templating via a CGI script. It’s slightly more work, but much more server agnostic. Luckily, caddy has a third party module to support CGI and an amazing build tool, xcaddy, to produce supporting binaries. We’ll see where my ideas take me, but I know I’ll be using Caddy for a lot in the future! Thank you Matt Holt for the amazing project!