Open
Description
When using precompressed
static files, the Content-Length
header seems to be missing.
Basically, I want to get the rough file size of compressed resources using HEAD
requests. encode
doesn't return the Content-Length
as described in #4902, but the suggested solution with precompressed
doesn't work for me. The precompressed files are present (index.html.zst
, index.html.gz
, index.html.br
).
I tested this same scenario with nginx
's gzip_static on;
directive, and it works like expected.
I tested using a browser and these curl commands:
$ curl -I HEAD http://localhost:8080/
HTTP/1.1 200 OK
Accept-Ranges: bytes
Content-Length: 1210
Content-Type: text/html; charset=utf-8
Last-Modified: Thu, 01 Jan 1970 00:00:01 GMT
Server: Caddy
Vary: Accept-Encoding
Date: Tue, 27 May 2025 16:46:08 GMT
$ curl -H "Accept-Encoding: gzip" -I HEAD http://localhost:8080/
HTTP/1.1 200 OK
Accept-Ranges: bytes
Content-Encoding: gzip
Content-Type: text/html; charset=utf-8
Last-Modified: Thu, 01 Jan 1970 00:00:01 GMT
Server: Caddy
Vary: Accept-Encoding
Date: Tue, 27 May 2025 16:46:02 GMT
This is the Caddyfile
I am using:
http://localhost:8080 {
file_server {
precompressed
}
root * /var/www/
}
Caddy version 2.10.0
.