I've read through everything I can find in the backlog of issues and don't see a reference to how to do dns caching instead of resolving dns every time. There are modules already out that do the dns lookup caching already, but I can't figure out how to make request use them.
Specifically we are seeing random dns.lookup calls that can take seconds due to network latency. Ideally would like to put something in front of requests call to dns.lookup and have it provide the cached result if/when slowdown occur.
Any ideas?
You'll have to install a DNS caching server like dnsmasq, powerdns, unbound etc., and change /etc/resolv.conf
to point to the DNS server IP.
I just did so local fiddling to verify, and it looks like since yahoo/dnscache modifies the global DNS module, using it anywhere in your node app _should_ work across all of your HTTP requests, including those done via requestjs
.
So the answer is probably as simple as just adding this anywhere in your app:
require('dnscache')({ enable: true });
...should be all it takes.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Most helpful comment
I just did so local fiddling to verify, and it looks like since yahoo/dnscache modifies the global DNS module, using it anywhere in your node app _should_ work across all of your HTTP requests, including those done via
requestjs
.So the answer is probably as simple as just adding this anywhere in your app:
...should be all it takes.