node-http-proxy icon indicating copy to clipboard operation
node-http-proxy copied to clipboard

Add lookup option to override dns lookups

Open oBusk opened this issue 2 years ago • 0 comments

The cause of this is that when proxying api requests to a hostname, node will perform a dns query for every single request, which adds unnecessary overhead. While I was investigating I found https://github.com/nodejs/node/issues/5893 and understood that there is no built in dns caching in node and that it seemingly bypasses OS dns cache. Adding a dns cache into http-proxy would clearly not be optimal, but by exposing the lookup option for request() we can customize the dns lookup that http-proxy performs and add our own cache, or inject https://www.npmjs.com/package/dns-lookup-cache or something similiar. (fixes http-party/node-http-proxy#653)

This configuration would also allow to customize the DNS lookup (fixes http-party/node-http-proxy#1315)

One problem with this is that the request() lookup option is only available in node v12 and later, so using the option when running node 8/10 would not have any effect. shouldn't implode either, but does nothing.

oBusk avatar Feb 24 '22 21:02 oBusk