aboutsummaryrefslogtreecommitdiff
path: root/plugin/cache/cache.go
diff options
context:
space:
mode:
authorGravatar Chris O'Haver <cohaver@infoblox.com> 2022-06-17 15:48:57 -0400
committerGravatar GitHub <noreply@github.com> 2022-06-17 15:48:57 -0400
commitdded10420b8a477ebd86cd2ceed9207a42c226cc (patch)
tree6b0679260b212428c74a3fbdc6ee3013d6460e0b /plugin/cache/cache.go
parentd60ce0c8d4fd647e880a118f469e8239d6effc7d (diff)
downloadcoredns-dded10420b8a477ebd86cd2ceed9207a42c226cc.tar.gz
coredns-dded10420b8a477ebd86cd2ceed9207a42c226cc.tar.zst
coredns-dded10420b8a477ebd86cd2ceed9207a42c226cc.zip
plugin/cache: Add option to adjust SERVFAIL response cache TTL (#5320)
* add servfail cache opt Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
Diffstat (limited to 'plugin/cache/cache.go')
-rw-r--r--plugin/cache/cache.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/plugin/cache/cache.go b/plugin/cache/cache.go
index fb84fcec0..fc42866ac 100644
--- a/plugin/cache/cache.go
+++ b/plugin/cache/cache.go
@@ -32,6 +32,7 @@ type Cache struct {
pcap int
pttl time.Duration
minpttl time.Duration
+ failttl time.Duration // TTL for caching SERVFAIL responses
// Prefetch.
prefetch int
@@ -59,6 +60,7 @@ func New() *Cache {
ncache: cache.New(defaultCap),
nttl: maxNTTL,
minnttl: minNTTL,
+ failttl: minNTTL,
prefetch: 0,
duration: 1 * time.Minute,
percentage: 10,
@@ -158,8 +160,7 @@ func (w *ResponseWriter) WriteMsg(res *dns.Msg) error {
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
+ duration = w.failttl
} else {
duration = computeTTL(msgTTL, w.minpttl, w.pttl)
}