brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: optimistic caching makes AdGuard Home answer DNS from expired entries

Network and access
~/tips/tip-adguard-home-optimistic-cache

dns:

Answer repeat lookups instantly while AdGuard Home refreshes the record in the background.

When a cached DNS answer expires, the next lookup has to wait for the upstream. Optimistic caching skips that wait: AdGuard Home serves the old answer right away and fetches a fresh one in the background.

Turn it on in DNS settings, under DNS cache configuration, or in the YAML:

dns:
  cache_enabled: true
  cache_optimistic: true

The answer from an expired entry goes out with a very short TTL, 10 seconds in current versions according to the docs, so the client asks again soon and then gets the refreshed record. Recent versions also let you set how long expired entries are kept with cache_optimistic_max_age.

On a home network it makes browsing feel a bit snappier, because many lookups are for the same few hundred names all day.

The trade-off is that you sometimes get an answer that is no longer correct. For most sites that does not matter. It does when you just moved a service to a new IP and wonder why one client still goes to the old one for a moment. While testing DNS changes, I’d switch this off for a while.

As always with the YAML: stop AdGuard Home before editing it.

Further reading: AdGuard Home configuration

Going deeper: Guide: AdGuard Home with Unbound: resolve DNS yourself instead of asking Cloudflare or your ISP

More Network and access tips scp -3 alice@server-a:/var/backups/db.sql.gz bob@server-b:/srv/restore/ tailscale exit-node suggest tailscale lock sign nodekey:1abddef1 tlpub:abcdef12 wg genpsk > peer1.psk Table = off All Network and access tips (163) All topics

Link