From a38c2d8ddf7384ad23660d9dde6d18fab5ef3b0f Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Wed, 18 Dec 2024 07:28:06 -0800 Subject: [PATCH] fix: add ETag header for bot/scraper page. For #4020 --- webserver/handlers/index.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/webserver/handlers/index.go b/webserver/handlers/index.go index 5fa7e9c0e..fb75c2982 100644 --- a/webserver/handlers/index.go +++ b/webserver/handlers/index.go @@ -2,6 +2,7 @@ package handlers import ( "bytes" + "crypto/md5" // nolint:gosec "encoding/json" "fmt" "net/http" @@ -199,7 +200,7 @@ func handleScraperMetadataPage(w http.ResponseWriter, r *http.Request) { // Set a cache header middleware.SetCachingHeaders(w, r) - + w.Header().Set("ETag", fmt.Sprintf("%x", md5.Sum(b.Bytes()))) // nolint:gosec w.Header().Set("Content-Type", "text/html") if _, err = w.Write(b.Bytes()); err != nil { log.Errorln(err)