From be8b29cd4d428eb85fb8cd97b439b3af4d451beb Mon Sep 17 00:00:00 2001 From: Kun Chang Date: Mon, 8 Apr 2019 18:15:05 +0800 Subject: [plugin/cache] cache failures (#2720) * cache failures * use ServerError --- plugin/cache/cache.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'plugin/cache/cache.go') diff --git a/plugin/cache/cache.go b/plugin/cache/cache.go index bc82bb604..69de55f17 100644 --- a/plugin/cache/cache.go +++ b/plugin/cache/cache.go @@ -163,6 +163,9 @@ func (w *ResponseWriter) WriteMsg(res *dns.Msg) error { var duration time.Duration if mt == response.NameError || mt == response.NoData { duration = computeTTL(msgTTL, w.minnttl, w.nttl) + } else if mt == response.ServerError { + // use default ttl which is 5s + duration = minTTL } else { duration = computeTTL(msgTTL, w.minpttl, w.pttl) } @@ -206,7 +209,7 @@ func (w *ResponseWriter) set(m *dns.Msg, key uint64, mt response.Type, duration i := newItem(m, w.now(), duration) w.pcache.Add(key, i) - case response.NameError, response.NoData: + case response.NameError, response.NoData, response.ServerError: i := newItem(m, w.now(), duration) w.ncache.Add(key, i) -- cgit v1.2.3