I work with a team to develop a web service and client, each of us, of course, working on our own machines. To keep things simple and more consistent, we use similar domains in the code and update /etc/hosts to resolve those domains to localhost.
- works fine for my web browser; response times are snappy
- curl and wget take ~4 seconds to resolve DNS before successfully completing the request
I did find the --resolve flag for curl which resolves the delay, but I could just as well use 127.0.0.1 and define the headers necessary to get the same effect.
with flag (and updated /etc/hosts file)
# /etc/hosts
...
127.0.0.1 mp-api.example.local
command
curl -k -o /dev/null -s -w %{time_connect}:%{time_starttransfer}:%{time_total}\\n \
--resolve mp-api.example.local:8094:127.0.0.1 \
-H 'Host: mp-api.example.local:8094' \
'https://mp-api.example.local:8094/api/categories/tree.json'
with 127.0.0.1
curl -k -o /dev/null -s -w %{time_connect}:%{time_starttransfer}:%{time_total}\\n \
-H 'Host: mp-api.example.local:8094' \
'https://127.0.0.1:8094/api/categories/tree.json'
What are some of the reasons for the delay in DNS resolution for tools like curl and wget? And what are some effective ways of troubleshooting that delay?
