I had some trouble figuring out why http://localhost, was responding slow compared to 127.0.0.1 when accessing my local apache http server. It turned out that by default the hosts file contains the following line:
# 127.0.0.1 localhost
By uncommenting this line, as follows (remove the hash):
127.0.0.1 localhost
A DNS look-up will then never be performed before it is determined that localhost is actually 127.0.0.1.