-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Content-Length header seems to be missing for precompressed files #7040
Copy link
Copy link
Closed
Labels
upstream ⬆️Relates to some dependency of this projectRelates to some dependency of this project
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 GMTThis is the Caddyfile I am using:
http://localhost:8080 {
file_server {
precompressed
}
root * /var/www/
}
Caddy version 2.10.0.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
upstream ⬆️Relates to some dependency of this projectRelates to some dependency of this project