middleware/cache: only cache query and responses (#397)
Extent typify to check the transfers, dynamic updates and notifies. Extend *cache* to not put these in the cache. Fixes #393
This commit is contained in:
parent
4318dfbf02
commit
e89c4b5c28
2 changed files with 36 additions and 6 deletions
10
middleware/cache/cache.go
vendored
10
middleware/cache/cache.go
vendored
|
@ -29,13 +29,16 @@ type Cache struct {
|
|||
pttl time.Duration
|
||||
}
|
||||
|
||||
// Return key under which we store the item.
|
||||
// Return key under which we store the item. The empty string is returned
|
||||
// when we don't want to cache the message. Currently we do not cache Truncated, errors
|
||||
// zone transfers or dynamic update messages.
|
||||
func key(m *dns.Msg, t response.Type, do bool) string {
|
||||
// We don't store truncated responses.
|
||||
if m.Truncated {
|
||||
// TODO(miek): wise to store truncated responses?
|
||||
return ""
|
||||
}
|
||||
if t == response.OtherError {
|
||||
// Nor errors or Meta or Update
|
||||
if t == response.OtherError || t == response.Meta || t == response.Update {
|
||||
return ""
|
||||
}
|
||||
|
||||
|
@ -65,6 +68,7 @@ func (c *ResponseWriter) WriteMsg(res *dns.Msg) error {
|
|||
do = opt.Do()
|
||||
}
|
||||
|
||||
// key returns empty string for anything we don't want to cache.
|
||||
key := key(res, mt, do)
|
||||
|
||||
duration := c.pttl
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue