The Cache plugin in lazydns provides DNS response caching with advanced features like lazy refresh, stale-serving, and prefetching. This guide explains all configuration options and how to optimize caching for your DNS server.
sizesize: 2048negative_cachenegative_cache: falsenegative_ttlnegative_ttl: 600enable_lazycacheenable_lazycache: truelazycache_thresholdlazycache_threshold: 0.1cache_ttlcache_ttl: 600enable_prefetchenable_prefetch: trueprefetch_thresholdprefetch_threshold: 0.2- tag: cache
type: cache
args:
size: 1024
negative_cache: true
negative_ttl: 300
- tag: cache
type: cache
args:
size: 2048
negative_cache: true
negative_ttl: 300
enable_lazycache: true
lazycache_threshold: 0.05
- tag: cache
type: cache
args:
size: 1024
negative_cache: true
negative_ttl: 300
enable_lazycache: false # Disable to test stale-serving
cache_ttl: 600
- tag: cache
type: cache
args:
size: 5000
negative_cache: true
negative_ttl: 600
enable_lazycache: true
lazycache_threshold: 0.1
cache_ttl: 1800
size: 1024 and monitor memory usage.negative_cache: false if you prefer to re-query failed domains.enable_lazycache for hot domains to reduce latency.lazycache_threshold (e.g., 0.02) for more aggressive refresh.cache_ttl to 2-3x typical DNS TTL for stale-serving benefits./api/cache/control).High Cache Miss Rate
size if cache is full.!qname conditions).Stale Responses Not Working
cache_ttl is set and greater than message TTL.enable_lazycache to isolate stale-serving behavior.Memory Issues
size or disable negative_cache.top or admin API.Cache hit: Normal cache hit.Lazycache threshold REACHED: Proactive refresh triggered.LazyCache TTL hit (stale entry): Stale-serving activated.Storing response in cache: New entry cached with TTL info.Use sequence conditions to skip caching for specific domains:
- matches: "!qname example.com"
exec: $cache
Cache works well with:
hosts: Cache static responses.forward: Cache upstream responses.ttl: Modify TTLs before caching.If migrating from other DNS servers:
rrset-cache-size and msg-cache-size.max-cache-size and max-ncache-ttl.cache_ttl replaces lazy_cache_ttl.Adjust sizes based on your query patterns and available memory.