Tales from the Evil Empire

Bertrand Le Roy's blog

News


Bertrand Le Roy

BoudinFatal's Gamercard

Tales from the Evil Empire - Blogged

Blogs I read

My other stuff

Archives

Why are scripts slow to load in Firefox when using Visual Studio’s built-in development Web server (a.k.a. Cassini)?

If you’ve been doing some script development in Visual Studio and Firebug, you may have experienced something like this:
Slow script loading with Firefox and Cassini

Notice how all resources take more than a second to load? Loading of scripts being sequential doesn’t help either.

And of course, the more scripts you have on the page, the worse it gets. I’ve seen fairly simple pages take around 15 seconds to load because of this bug.

I’m not quite sure where that bug comes from, but the good news is I have two solutions for you. First, you can configure Visual Studio to use IIS (when you do “new web site”, choose HTTP as the location, then “local IIS”). But the easiest is just to replace “localhost” in the browser address bar with “127.0.0.1”. Here’s the performance of the same page as above, using that address:
FastFFCassini

From 6 seconds down to 215 milliseconds. Not bad, eh? Multiply this by the number of times you load pages in this configuration during a typical work day and you’ve got what I think is a pretty useful trick ;) Of course, not having this bug in the first place would be ideal…

I hope this helps.

UPDATE: Dan Wahlin has an explanation for this, which is an issue with DNS and IPv6 support in Firefox. An alternate workaround is to disable IPv6 in Firefox. Thanks to Marc for pointing me to this post.
http://weblogs.asp.net/dwahlin/archive/2007/06/17/fixing-firefox-slowness-with-localhost-on-vista.aspx

Comments

MarcLaFleur said:

This is caused by an IPv6 DNS problem. By using the 127.0.0.1 address you're getting around this problem by a) using an IPv4 address and b) skipping DNS entirely.

You can also fix this by disabling IPv6 support in Firefox.  Simply navigate to about:config and change the property “network.dns.disableIPv6” to true.

Credit to Dan Wahlin for finding this (http://weblogs.asp.net/dwahlin)

# December 29, 2008 4:14 PM

takepara said:

edit your hosts file.

%SystemRoot%\system32\drivers\hosts

127.0.0.1       localhost

#::1             localhost <- comment out here

# December 29, 2008 8:56 PM

Ran Davidovitz said:

this issue made me crazy!, thanks for sharing.

# January 27, 2009 6:52 AM