@marcel91200 / caddy Mirror · read-only / commits / 5bd9c490
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 13, 01:45 UTC

fileserver: Don't set Etag if mtime is 0 or 1 (close #5548) (#5550)

Matt Holt committed May 22, 2023 at 14:17 UTC 5bd9c49042112183f0902a7ce6252aebf58e1ac9
1 file changed +5 -1
modules/caddyhttp/fileserver/staticfiles.go
+5 -1
@@ -616,7 +616,11 @@ func (fsrv *FileServer) notFound(w http.ResponseWriter, r *http.Request, next ca
616 // Prefix the etag with "W/" to convert it into a weak etag.
617 // See: https://tools.ietf.org/html/rfc7232#section-2.3
618 func calculateEtag(d os.FileInfo) string {
619 - t := strconv.FormatInt(d.ModTime().Unix(), 36)
619 + mtime := d.ModTime().Unix()
620 + if mtime == 0 || mtime == 1 {
621 + return "" // not useful anyway; see issue #5548
622 + }
623 + t := strconv.FormatInt(mtime, 36)
624 s := strconv.FormatInt(d.Size(), 36)
625 return `"` + t + s + `"`
626 }