Every time Caddy comes up next to nginx, somebody mentions the shorter config and leaves it there, as if that settles the comparison. It never settles anything for…

Every time Caddy comes up next to nginx, somebody mentions the shorter config and leaves it there, as if that settles the comparison. It never settles anything for me, because a shorter file doesn't say what happened to the parts that didn't fit in it.

So I took an nginx config close to one I've actually run, with a proxy route, a rate limit, a static folder and a redirect, rewrote it as a Caddyfile directive by directive, and checked each one against a real request instead of trusting that it looked right.

I set this up locally with Docker: two matched pairs of containers, each a plain Python backend behind either nginx 1.29 or Caddy 2.11, on their own bridge network, nothing shared between them so neither measurement could leak into the other. The nginx side proxies /api/, serves a static JS file from /static/, rate-limits the API route, and redirects one old path. I wrote the Caddy side to do exactly the same four things, then tested both the same way.

The config did get shorter Stripped of blank lines and lone braces, the nginx config is 18 lines. The Caddy version that reproduces logging, the redirect, gzip, and the static route is 11 lines — about 39% shorter. That's a real difference and it holds even after I'd gone back and fixed two things I'd missed the first time (below). But it comes with an asterisk: it doesn't include rate limiting, because the stock Caddy image can't do that at all. More on that in a minute.

nginx.conf Caddyfile meaningful lines 18 11 needs explicit access logging no (logs by default) yes, see below handles the rate limit yes no, not without a custom build The redirect that silently stopped working nginx's return 301 /api/ping; inside a location /old-path block is about as simple as a redirect gets. I translated it the way it reads: put the target path in a handle /old-path block and tell Caddy to redirect.

Source disclosure

This is a source-linked briefing. Read the original report from Dev Community .