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 #653)
This configuration would also allow to customize the DNS lookup (fixes #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.