blocky do not cache nxdomain
Hi ๐๐ผ
It would be cool if this could be default, or configurable. Usually I'm testing things in my homelab and my service isn't online just yet when I try to hit it. Blocky caches that nxdomain so I always need to bounce the container to clear the cache.
Thanks!
3 Answer:
Hi,
I think, it makes sense to cache negative results. The default TTL is 30 min (https://github.com/0xERR0R/blocky/blob/97a4a2eff34c5173410aada6c46c2cebff2616ad/resolver/caching_resolver.go#L35). Making it configurable is a good idea ๐
Would setting this to -1
or 0
allow for me to disable caching of "negative" results?
Do you mean, if you change the code? No, it must be positive (see comment of the caching library: https://github.com/0xERR0R/go-cache/blob/58f35d51010e75d5b0d8963a21d6053a10d0791d/cache.go#L55). As quickfix you can set it to 1ns.
I would change the logic, if configured negativeCacheTime is <=0 - don't cache negative result. If positive, use it as cache time. I would also reduce the default value from 30m to something smaller (5m or maybe 1m).