admin: better Cache-Control handling (#8330)

pull/8331/head
Kévin Dunglas 2026-11-01 22:58:15 +01:00 committed by GitHub
parent 9dd12fdb5d
commit 84eaf50b7b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 2 deletions

View File

@ -45,6 +45,7 @@ import (
"github.com/prometheus/client_golang/prometheus"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"golang.org/x/net/http/httpguts"
"github.com/caddyserver/caddy/v2/caddyconfig/warning"
"github.com/caddyserver/caddy/v2/internal"
@ -1085,7 +1086,7 @@ func handleConfig(w http.ResponseWriter, r *http.Request) error {
body = buf.Bytes()
}
forceReload := r.Header.Get("Cache-Control") == "must-revalidate"
forceReload := httpguts.HeaderValuesContainsToken(r.Header["Cache-Control"], "must-revalidate")
err := changeConfig(r.Method, r.URL.Path, body, r.Header.Get("If-Match"), forceReload)
if err != nil && !errors.Is(err, errSameConfig) {

View File

@ -24,6 +24,8 @@ import (
"strings"
"sync"
"golang.org/x/net/http/httpguts"
"github.com/caddyserver/caddy/v2"
)
@ -107,7 +109,7 @@ func (adminLoad) handleLoad(w http.ResponseWriter, r *http.Request) error {
body = result
}
forceReload := r.Header.Get("Cache-Control") == "must-revalidate"
forceReload := httpguts.HeaderValuesContainsToken(r.Header["Cache-Control"], "must-revalidate")
err = caddy.Load(body, forceReload)
if err != nil {