dnscache icon indicating copy to clipboard operation
dnscache copied to clipboard

Ttl cache from DNS server

Open PaquitoSoft opened this issue 9 years ago • 6 comments

Hi! Reading about the possibility to add caching capabilities to nodejs DNS module (which it seems it's not going to happen), there's a comment in this thread with a warning about dnscache module. Here is the link to the thread.

Here is the comment:

Just to add my two cents in, it is very dangerous to use the dnscache package because it does not respect the ttl set by the dns server. This means that you could potentially have a bad dns cache for some time. By implementing a OS level solution, you'll get all the benefits mentioned above in addition to the reassurance that your dns entries will always be correct.

Is there any chance for this module to respect the TTL set by the DNS server?

Thanks.

PaquitoSoft avatar Oct 26 '16 10:10 PaquitoSoft

I answer my own question. Currently there's no way in nodejs to get the TTL set by the DNS server. However, it seems they will implement it, at least for the dns.resolve function (https://github.com/nodejs/node/pull/9296)

PaquitoSoft avatar Oct 27 '16 08:10 PaquitoSoft

Until this is supported by nodejs itself (7.2?), we are not going to add such a feature to this module. Instead, the assumption is that those using this module understand the risks involved with overriding the DNS server TTL. (In most cases, the expectation is that the TTL of dnscache will be set to a smaller value than most DNS server TTLs since its primary purpose is to prevent overloading/latency of said DNS servers).

evantorrie avatar Nov 29 '16 05:11 evantorrie

This is now supported as of Node.js 7.2 . Here are the docs for the new feature.

robertrossmann avatar Dec 22 '16 19:12 robertrossmann

This was also backported to 6 today (6.11.0). https://github.com/nodejs/node/blob/4c5cbb7c8367abde6409ce68eee0e5eb5f07903d/doc/changelogs/CHANGELOG_V6.md#6.11.0

SimenB avatar Jun 06 '17 20:06 SimenB

Use https://www.npmjs.com/package/lookup-dns-cache

eduardbme avatar Jan 19 '18 13:01 eduardbme

@PaquitoSoft @evantorrie @robertrossmann @SimenB @roccomuso

Hello! I've found that this module is unsupported and has some bugs. I may propose to use our module that was tested in production and highload environments. Also we have good unit and functional tests with 100% coverage, multi-records resolving and TTL support. Here it is: https://github.com/LCMApps/dns-lookup-cache

WoZ avatar Mar 25 '19 16:03 WoZ