#772·blocky

Cache prefetching only takes the threshold into account on first insertion

Author: ThinkChaosCreated Nov 27, 2022Updated Sep 15, 2026

The way the caching resolver manages its prefetchingNameCache, the count for a domain expires and resets back to 0 only if the domain was not queried at all in the expiration duration.
This means that once a domain is "prefetchable", a single query per expire duration is enough to keep it there as it will reset the expiration date for the domain: https://github.com/0xERR0R/blocky/blob/6c616898b87a190e439247891ba3178b22302e9d/resolver/caching_resolver.go#L216-L221

Instead of having a single counter per domain, we need at least prefetchThreshold, so each can have their own expiry time. I think the cleanest way to implement the fix would be to use a time series that supports setting a max entry cap.

Note that I haven't tried to trigger this issue, and wrote this based on my understanding of the code, which could be wrong.