Cassini 上的 ASP.NET MVC:我如何强制“内容"?目录返回 304s 而不是 200s? [英] ASP.NET MVC on Cassini: How can I force the "content" directory to return 304s instead of 200s?

查看:11
本文介绍了Cassini 上的 ASP.NET MVC:我如何强制“内容"?目录返回 304s 而不是 200s?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

场景:我有一个在 Visual Studio 2008 中开发的 ASP.NET MVC 应用程序.有一个名为Content"的根文件夹,用于存储图像和样式表.当我在本地运行(使用 Cassini)并浏览我的应用程序时,总是下载内容"目录中的每个资源.使用 Firebug,我可以验证 Web 服务器是否返回 HTTP 200(ok").

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").

期望:我希望 Cassini 返回 HTTP 304(未修改")而不是 200.这是在 IIS7 下运行站点时的行为.

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.

推理:我正在开发的网站有大量静态资源(通常每页多达 40 个).在 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.

在 IIS7 上渲染不到 1 秒的页面在 Cassini 上渲染需要 30 多秒.对于我来说,每隔几分钟上传整个网站并从那里进行测试实际上更快.(是的,我承认这是反常和疯狂的.)

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.)

那么:我如何指示/欺骗 Cassini 像 IIS7 那样处理内容"目录?

推荐答案

您确定问题是缓存吗?因为当我在 Cassini 上运行应用程序时,内容确实在我的机器上正确缓存.

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

我认为您遇到的问题可能是 Firefox 在解析 IPv6 地址时性能不佳,这会导致加载诸如 http://localhost:55555.

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.

我为改变这种行为所做的是将 about:config 上的 network.dns.disableIPv6 首选项更改为 Firefox 上的 true.我建议尝试一下.

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.

这篇关于Cassini 上的 ASP.NET MVC:我如何强制“内容"?目录返回 304s 而不是 200s?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆