The cache plugin stores DNS responses to reduce upstream traffic and improve latency. It supports TTL-respecting caching, negative caching, LRU eviction, LazyCache background refresh, stale-serving, and persistence across restarts.
cache_ttl: return stale response while refreshingsize (number, default: 1024): maximum cache entriesnegative_cache (bool, default: false): cache error responses
negative_ttl (number, default: 300): TTL for negative entries (seconds)enable_lazycache (bool, default: false): refresh hot entries in background
lazycache_threshold (number, default: 0.05): fraction of original TTL below which refresh triggerscache_ttl (number, default: disabled): stale-serving window in secondsdump_file (string, optional): path to persist cache across restarts
dump_interval (number, default: 600): seconds between periodic dumpsWhen dump_file is set, the cache is saved to a binary file on shutdown and periodically (every dump_interval seconds, or after 1024 writes). On startup, the file is loaded and entries that have not yet expired are restored. Entries are stored in DNS wire format with their original TTL and cache timestamp.
plugins:
- tag: my_cache
type: cache
args:
size: 2048
negative_cache: true
negative_ttl: 300
enable_lazycache: true
lazycache_threshold: 0.05
cache_ttl: 600
dump_file: /var/lib/lazydns/cache.dump
dump_interval: 300
lazydns_cache_hits_total / lazydns_cache_misses_totallazydns_cache_evictions_total / lazydns_cache_expirations_totallazydns_cache_size (current entries)