NLnetLabs / unbound

Unbound is a validating, recursive, and caching DNS resolver.
https://nlnetlabs.nl/unbound
BSD 3-Clause "New" or "Revised" License
3.14k stars 358 forks source link

[FR] Serving expired records in the cache by type. #856

Open alpominth opened 1 year ago

alpominth commented 1 year ago

Here in my tests, prefetch option only works when serve-expired is enabled.

Here is one of my configuration files:

server:
  interface: 127.0.0.1
  interface: ::1
  port: 53
  cache-max-ttl: 21600
  cache-min-ttl: 21600
  cache-max-negative-ttl: 21600
  val-bogus-ttl: 0
  infra-host-ttl: 21600
  prefetch: yes
  serve-expired: yes
  serve-expired-ttl: 2592000
  delay-close: 10000
  chroot: ""
  username: "permcache"
  directory: ""
  pidfile: ""
  do-not-query-localhost: no
  module-config: "validator cachedb iterator"

cachedb:
  backend: redis
  # redis-server-host: ::1
  # redis-server-port: 6379
  redis-server-password: "blah123"
  redis-server-path: "/opt/permcache/db/redis-server.sock"
  redis-timeout: 5000

forward-zone:
  name: "."
  forward-addr: ::1@10053

/\ Prefetch works, but the negative and host cache are cached for 1 month when prefetching is enabled, I would like to set a very short caching time for them, 1 or 2 days.

Options for controlling the expired host cache and negative cache separately would be a very good idea, as negative and host entries would have different TTLs.

The options could be:

serve-expired-negative-ttl: <seconds>
serve-expired-infra-host-ttl: <seconds>
alpominth commented 1 year ago

@gthess @wcawijngaards

Any thoughts?

I think that the options I suggested are reasonable, because when using Unbound for persistent caching and with prefetching, storing and serving a NXDOMAIN/Empty response for a long time should be avoided.