Caddy Fails to serve static files

The handle directive lets you define mutually exclusive request handling branches. This means that if one is matched, no other handle will execute; only the first matched handle will run.

The Caddyfile adapter will sort the handle blocks in order of most specific request matcher to the least specific. The one with a path matcher is more specific than the one without a matcher, because no matcher means “match all requests”, so that should be tried last.

Essentially we’re taking advantage of the sorting behaviour of handle blocks to make sure the directives run in the order we want.

For a deeper dive, you can read this wiki article:

2 Likes