3

I am looking for a way to automatically refresh entries in my cache if it expires.

For example, example.com has a TTL of 60, i would like to automatically refresh it if it expires so that when users query example.com a fresh version is already in the cache.

Is this possible within bind?

Thanks!

1
  • I hate to ask the question... but why would you need to pre-cache DNS info? When a user asks... it gets cached.
    – TheCompWiz
    Sep 6, 2013 at 14:14

2 Answers 2

2

BIND supports a technique called prefetch. Using prefetch BIND will automatically refresh entries that are about to expire. The following is the syntax of prefetch.

 sudo vim /etc/bind/named.conf.options
 ...
 options {
 ...
 prefetch 2 9;
};
...

As you can see this has two numbers, the trigger (here 2), and the eligibility (here 9). This tells BIND to refresh DNS entries for all entries whose initial TTL was greater than 9 seconds, if the remaining TTL falls below 2 seconds. Thus it will not blindly refresh all entries, instead it will only monitor entries which have an initial TTL greater than eligibility, and once the remaining TTL for these entries falls below the trigger value it will refresh them. The values of eligibility, and trigger are in seconds.

So, let's say example.com has a TTL of 60 seconds (i.e. TTL when the record was fetched), I want to ensure that if the remaining TTL falls below 10 seconds, the entry should be refreshed. The following will be my prefetch option in the config file.

prefetch 10 60

Further reading: https://kb.isc.org/article/AA-01122/0

1

No, there isn't. The cache is designed to automatically "record" entries when they are accessed for the first time for faster access later. There's no performance gain to "pre-caching" entries like you're describing.

6
  • 2
    While it is not practical to do this on large scale servers i think it does offer gains for small or personal servers because most people access the same domains every day and these records could as well be kept fresh in the cache.
    – Susan
    Sep 6, 2013 at 13:55
  • There's no sense in precaching as the first "hit" will cache the entry up to the TTL. I suppose you could issue a DNS query shortly after the TTL expires to re-cache, but Bind doesn't have this function. You might as well set a longer TTL.
    – Nathan C
    Sep 6, 2013 at 13:57
  • Thanks, then i will have to write my own tool to do this. Yes but the first hit takes time and some sites which i do not control have a very very short TTL.
    – Susan
    Sep 6, 2013 at 13:59
  • 1
    So you want to cache for longer than the authoritative TTL? That's all kinds of wrong. Sep 6, 2013 at 14:05
  • @TomO'Connor not really... it sounds like she's trying to pre-populate the cache. As the TTL is valid... and not being overridden... it's not really wrong. I honestly can't see the logic in doing this... as it will be cached the first time someone asks... and will be valid for all users that query against it... but /meh
    – TheCompWiz
    Sep 6, 2013 at 14:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .