djbdns

djbdns contains tinydns, which is a dns server, and dnscache, which is a dns cache. Normally, dnscache does not accept answers from dns servers outside the chain from the root servers to the authorative server. Answers are cached for later queries. If you restart dnscache, this in-memory cache gets lost and it has to be rebuild on next startup by querying the root servers, the tld servers, and so on. This procedure can be a waste of traffic and time. This is totally unnecessary, since most records have a long time-to-live value.

cache save patch for dnscache

After applying my patch, re-compiling and re-installing djbdns, if you send dnscache a SIGTERM, it will save its cache to $ROOT/cache/cache and shutdown. This file is read upon next startup automatically. Of course you have to create the directory $ROOT/cache first and make it writeable for the account under which dnscache runs.
The cache file can be copied from a big endian to a little endian machine and vice versa as every integer value is strictly stored in big endian format. The cache file is at least 4 bytes per entry smaller than $CACHESIZE.

download

djbdns-1.05.cache-save.patch.diff