diff options
Diffstat (limited to 'core/dnsserver/server_https.go')
-rw-r--r-- | core/dnsserver/server_https.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/core/dnsserver/server_https.go b/core/dnsserver/server_https.go index c9f0da0cd..cf5d08a45 100644 --- a/core/dnsserver/server_https.go +++ b/core/dnsserver/server_https.go @@ -7,6 +7,10 @@ import ( "net" "net/http" "strconv" + "time" + + "github.com/coredns/coredns/plugin/pkg/dnsutil" + "github.com/coredns/coredns/plugin/pkg/response" "github.com/miekg/dns" ) @@ -129,8 +133,11 @@ func (s *ServerHTTPS) ServeHTTP(w http.ResponseWriter, r *http.Request) { buf, _ := dw.Msg.Pack() + mt, _ := response.Typify(dw.Msg, time.Now().UTC()) + age := dnsutil.MinimalTTL(dw.Msg, mt) + w.Header().Set("Content-Type", mimeTypeDOH) - w.Header().Set("Cache-Control", "max-age=128") // TODO(issues/1823): implement proper fix. + w.Header().Set("Cache-Control", fmt.Sprintf("max-age=%f", age.Seconds())) w.Header().Set("Content-Length", strconv.Itoa(len(buf))) w.WriteHeader(http.StatusOK) |