Since setting up my development environments on Mac OS X Lion (brand new macbook air purchased in January 2012), I have noticed that resolving to a virtual host is very slow (around 3 seconds) the first time but after that is fast as long as I continue loading it regularly.

If I leave it untouched for a couple of minutes and then reload again, the first reload is (again) painfully slow; seems like something is being cached. 

As can be seen below I am not using the .local TLD.

My setup: Apache 2 - MySQL - PHP installed and enabled - added a couple of virtual hosts one of which I created for localhost

My /etc/hosts:

```
127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost
fe80::1%lo0     localhost
127.0.0.1       myproject.dev
::1             myproject.dev
fe80::1%lo0     myproject.dev

```

My virtual host set-up in username.conf: 

```
NameVirtualHost *:80

<Directory "/Users/myusername/Sites/">
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

<VirtualHost *:80>
    ServerName localhost
    DocumentRoot /Users/myusername/Dropbox/dev_envs/
</VirtualHost>
<VirtualHost *:80>
    ServerName myproject.dev
    DocumentRoot /Users/myusername/Dropbox/dev_envs/myprojectname
</VirtualHost>

```
['https://Stackoverflow.com/questions/10064581', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/61232/']
There's another issue 10.7.\* to 10.8.4 for sites ending in `.local` which causes five second lookups. Details and solution courtesy Bram Van Damme’s [blog post found here](http://www.bram.us/2011/12/12/mamp-pro-slow-name-resolving-with-local-vhosts-in-lion-fix/).

> 
> “By default, any hostname ending in `.local` is treated as a Bonjour host rather than by querying the DNS server entries in Network preferences.”
> 
> 
> “To fix this problem (without having to rename each vhost) you need to add IPv6 entries for each of your vhosts in your `/etc/hosts` file:”
> 
> 
> 

```
::1 mysite.local
fe80::1%lo0 mysite.local
127.0.0.1 mysite.local

```
A dumb issue that led me to waste some considerable time: after applying [@Cleverlemming's answer](https://stackoverflow.com/a/17982964/1588706), I figured out that there were duplicated entries on the hosts file. Something like:

```
::1          site1.local site2.local site1.local site3.local site4.local
fe80::1%lo0  site1.local site2.local site1.local site3.local site4.local
127.0.0.1    site1.local site2.local site1.local site3.local site4.local

```

Then IP resolving for site3.local and site4.local takes these 5-seconds of death.