Skip to content

fix(dns): expire cached responses with their answers - #454

Open
omrzk wants to merge 1 commit into
nadoo:mainfrom
omrzk:fix/dns-answer-cache-ttl-453
Open

omrzk wants to merge 1 commit into
nadoo:mainfrom
omrzk:fix/dns-answer-cache-ttl-453

Conversation

@omrzk

@omrzk omrzk commented Oct 30, 2026

Copy link
Copy Markdown

CNAME-only answers currently receive a 1,800-second cache lifetime, regardless of the CNAME TTL. Mixed CNAME/address answers can also remain cached after the shortest-lived record expires.

Use the minimum TTL across the cached answer section, then apply the configured minimum/maximum overrides. When no positive lifetime remains, discard the cached response (including any previous stale entry) instead of applying the arbitrary fallback. Custom static records remain untouched. This also keeps the cache usable after all dynamic entries have been discarded. Negative responses without answer records are left uncached; this does not add SOA-based negative caching.

Fixes #453.

Validation: the original implementation fails seven of the new wire-response TTL cases. go test -race -p 2 ./... -count=1, 20 focused DNS race-test repetitions, go vet -p 2 ./..., go build -p 2 ./..., formatting and diff checks pass with Go 1.27.0 on Linux/amd64. Tests cover CNAME-only answers, mixed TTL order, zero TTLs, stale-entry replacement, minimum/maximum overrides, and an emptied cache; these are local DNS fixtures, not deployment testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DNS cache keeps CNAME-only A responses for 1800 seconds

1 participant