I am working on a asp.net web site, like normal user, we use asp.net developer server during coding and testing. Today, I found the firefox not cache any static file of my s
You could also host the page on your local IIS WebServer instead of running it in the VS Development Server. In IIS you can specify the expiration header settings to your needs.
Thanks everybody for helping this question. I believe I found the reason why FireFox seems very slow on window 7 box. I did not notice the slowness when I was using windows XP.
First all, Firefox will NOT cache any resource from asp.net web developer server. this fact does not change in XP or Window 7. When I use firebug check the resource downloading today, I noticed DNS lookup takes a couple of seconds. then I found out for window 7 default installation, the HOSTS file under windows\system32\driver\etc does not DNS entry 127.0.0.1 localhost. By adding this line to HOSTS file. my site is as fast as before.
you can try adding one of these to your page load function -
option 1
Response.ClearHeaders();
Response.AppendHeader("Cache-Control", "no-cache"); //HTTP 1.1
Response.AppendHeader("Cache-Control", "private"); // HTTP 1.1
Response.AppendHeader("Cache-Control", "no-store"); // HTTP 1.1
Response.AppendHeader("Cache-Control", "must-revalidate"); // HTTP 1.1
Response.AppendHeader("Cache-Control", "max-stale=0"); // HTTP 1.1
Response.AppendHeader("Cache-Control", "post-check=0"); // HTTP 1.1
Response.AppendHeader("Cache-Control", "pre-check=0"); // HTTP 1.1
Response.AppendHeader("Pragma", "no-cache"); // HTTP 1.1
Response.AppendHeader("Keep-Alive", "timeout=3, max=993"); // HTTP 1.1
Response.AppendHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT"); // HTTP 1.1
option 2
Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1))
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.Cache.SetNoStore()
You need to issue Expires header to make Firefox cache the files.
Otherwise, how do you think it could guess for how long does it need to cache the files?
According to my running of Fiddler2, it caches the files, ie 304s(Not Modified) responses are done
Same behanviour occurs in both IE 8 and FF 3.6.8 IE8 has to be set to Automatically check for new versions of a page for this to occur.
Running it on IIS causes both FF and IE to cache static content.
This caching is due to the webserver adding a last-modified header to the response.
You can get fiddler to listen to localhost
by using localhost.
instead ( http://weblogs.asp.net/asptest/archive/2008/08/13/tip-on-using-fiddler-with-cassini-and-localhost.aspx ).