Web / Caddy Server Interview questions
What is the purpose of the file_server directive?
file_server is Caddy's built-in static file handler. Once a site block has a file root set (usually via root *), file_server maps incoming request paths to files under that root and streams them back.
It automatically resolves index.html for directory-style requests, sets ETag and Last-Modified headers for caching, and honors Range request headers so clients can resume partial downloads of large files like videos. It can also be scoped to a subpath with a matcher, so only part of a site is served from disk while the rest is proxied elsewhere.
Without file_server, a root directive alone does nothing - root only tells Caddy where files live, while file_server is the handler that reads and returns them.
More Related questions...