Question about DNS cache

I have a question of understanding about the cache in Pi-hole.

I have Pi-hole v5.2.4 | Web Interface v5.4 | FTL v5.7 installed, with a local Unbound 1.13.1 as upstream DNS server.

Pi-hole is running with cache-size=300
Unbound is running with cache-min-ttl: 900

My expectation is, every entry in the Pi-hole cache has a TTL of 900 seconds (15 minutes) or more.

9 minutes after a restart with pihole restartdns the web interface shows:

DNS cache size: 300
DNS cache insertions: 372
DNS cache evictions: 0

After the above mentioned 9 minutes the oldest entries in the cache should still have a TTL of approx. 6 minutes = cache is full. Why there are 0 evictions?

I'd guess that cache-min-ttl is exclusively controlling unbound's cache, i.e. for how long unbound would cache an entry, but without altering the original TTL of a DNS reply.

You should be able to verify this by checking TTLs for short-lived records, e.g. via dig.

The setting does not modify the TTL of the answer send to the client but only in unbounds cache. At least that's how I understood

Time to live minimum for RRsets and messages in the cache. De-
fault is 0. If the minimum kicks in, the data is cached for
longer than the domain owner intended, and thus less queries are
made to look up the data. Zero makes sure the data in the cache
is as the domain owner intended, higher values, especially more
than an hour or so, can lead to trouble as the data in the cache
does not match up with the actual data any more.

No, cache-min-ttl is also the value with which requests are answered.

Result of dig @127.0.0.1 posteo.de or dig @127.0.0.1 gmail.com is

... 900 IN A ...

But I probably answered my own question while walking with the dog :man_facepalming:
I had not restarted Unbound. So its cache surely had entries with a short TTL, just a few seconds/minutes left.

Why do you want to have evictions? That means your cache is too small and valid records are being deleted. That's means additional lookups are required and new lookups will have the max ttl which will then cause even more evictions and generally a bad user experience and increased load.

There are zero evictions because there were not sufficient DNS requests going into the cache to cause existing entries to be evicted.

Is there a particular reason why you have Pi-hole cache restricted to 300 entries?

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.