lazydns

Cache Plugin Configuration Guide

Overview

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.

Configuration Options

Basic Settings

size

negative_cache

negative_ttl

LazyCache Features

enable_lazycache

lazycache_threshold

Stale-Serving (Extended Cache TTL)

cache_ttl

Prefetch (Experimental)

enable_prefetch

prefetch_threshold

Example Configurations

Basic Cache

- tag: cache
  type: cache
  args:
    size: 1024
    negative_cache: true
    negative_ttl: 300

With LazyCache

- tag: cache
  type: cache
  args:
    size: 2048
    negative_cache: true
    negative_ttl: 300
    enable_lazycache: true
    lazycache_threshold: 0.05

With Stale-Serving

- tag: cache
  type: cache
  args:
    size: 1024
    negative_cache: true
    negative_ttl: 300
    enable_lazycache: false # Disable to test stale-serving
    cache_ttl: 600

High-Performance Cache

- tag: cache
  type: cache
  args:
    size: 5000
    negative_cache: true
    negative_ttl: 600
    enable_lazycache: true
    lazycache_threshold: 0.1
    cache_ttl: 1800

Best Practices

Memory Usage

Performance Tuning

Monitoring

Troubleshooting

Common Issues

High Cache Miss Rate

Stale Responses Not Working

Memory Issues

Log Messages

Advanced Usage

Conditional Caching

Use sequence conditions to skip caching for specific domains:

- matches: "!qname example.com"
  exec: $cache

Integration with Other Plugins

Cache works well with:

Migration from Other DNS Servers

If migrating from other DNS servers:

Adjust sizes based on your query patterns and available memory.