diff --git a/modules/caddyhttp/fileserver/staticfiles.go b/modules/caddyhttp/fileserver/staticfiles.go index 5d54742ddb7..e1a767b3405 100644 --- a/modules/caddyhttp/fileserver/staticfiles.go +++ b/modules/caddyhttp/fileserver/staticfiles.go @@ -690,7 +690,12 @@ func (fsrv *FileServer) getEtagFromFile(fileSystem fs.FS, filename string) (stri if err != nil { return "", fmt.Errorf("cannot read etag from file %s: %v", etagFilename, err) } - return string(etag), nil + etagStr := string(etag) + + // Etags should not contain newline characters + etagStr = strings.ReplaceAll(etagStr, "\n", "") + + return etagStr, nil } return "", nil }