aboutsummaryrefslogtreecommitdiff
path: root/plugin/cache/cache.go
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/cache/cache.go')
-rw-r--r--plugin/cache/cache.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/plugin/cache/cache.go b/plugin/cache/cache.go
index b37e527cf..5d9bd746b 100644
--- a/plugin/cache/cache.go
+++ b/plugin/cache/cache.go
@@ -117,6 +117,19 @@ func (w *ResponseWriter) WriteMsg(res *dns.Msg) error {
return nil
}
+ // Apply capped TTL to this reply to avoid jarring TTL experience 1799 -> 8 (e.g.)
+ ttl := uint32(duration.Seconds())
+ for i := range res.Answer {
+ res.Answer[i].Header().Ttl = ttl
+ }
+ for i := range res.Ns {
+ res.Ns[i].Header().Ttl = ttl
+ }
+ for i := range res.Extra {
+ if res.Extra[i].Header().Rrtype != dns.TypeOPT {
+ res.Extra[i].Header().Ttl = ttl
+ }
+ }
return w.ResponseWriter.WriteMsg(res)
}