Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET MVC on Cassini: How can I force the "content" directory to return 304s instead of 200s?

Scenario: I have an ASP.NET MVC application developed in Visual Studio 2008. There is a root folder named "Content" that stores images and stylesheets. When I run locally (using Cassini) and browse my application, every resource from the "Content" directory is always downloaded. Using Firebug, I can verify that the web server returns an HTTP 200 ("ok").

Desired: I would like for Cassini to return HTTP 304 ("not modified") instead of 200. This is the behavior when running the site under IIS7.

Reasoning: The site I am working on has a large number of static resources (often as many as 40 per page). Browsing the site is very fast on IIS7, because these resources are (correctly) cached by the browser. However, browsing the site on my local machine is painfully slow.

Pages that render in under 1 second on IIS7 take over 30 seconds to render on Cassini. It's actually faster for me to upload the entire website every few minutes and test from there. (Yes, I recognize that this is perverse and crazy.)

So: how can I instruct/trick Cassini into treating the "Content" directory like IIS7 does?

like image 678
Portman Avatar asked Apr 27 '09 21:04

Portman


3 Answers

Are you sure the problem is caching? Because the content does get cached correctly on my machine when I run the application on Cassini.

I think the problem you're having could be Firefox's under-performance with resolving IPv6 addresses, which causes a very annoying delay on loads with addresses like http://localhost:55555.

What I did to change this behaviour was to change the network.dns.disableIPv6 preference on about:config to true on Firefox. I suggest trying that.

like image 64
Çağdaş Tekin Avatar answered Nov 03 '22 00:11

Çağdaş Tekin


I've had a similar problem in Chrome. To resolve this uncomment the IPv4 localhost line in you hosts file. Apparently these are commented by default in Windows 7.

127.0.0.1       localhost
#::1             localhost
like image 26
Robert Massa Avatar answered Nov 03 '22 00:11

Robert Massa


Another option for you is to simply skip Cassini and debug under IIS. It's pretty straightforward, and won't take you ten minutes to get up and running. Browse 20 of your pages on Cassini, and you've used that time anyway ;)

One thing I've noticed isn't always in the guides, is that if you want to debug on a different address than http://localhost/ you need to manually set the host to your local IIS. This is done by adding a line in the hosts file, located at

C:\Windows\system32\drivers\etc\hosts

Open the file with notepad (you need to "Run as Administrator" in order to be able to save if you're using Windows Vista and have User Account Control turned on...) and add your host. For example, to debug under http://mysite/ you add

mysite         127.0.0.1
like image 30
Tomas Aschan Avatar answered Nov 02 '22 23:11

Tomas Aschan