错误在:System.Web.UI.Page.InitOutputCache() 或 System.Web.Mvc 中?
我在一些控制器方法上使用带有输出缓存(OutputCache 属性)的 asp.net MVC,并且在 HTTP 标头中得到一些非常奇怪的结果。
当我将属性添加到处理主页面视图的控制器操作时。 内容:
Date Thu, 16 Jul 2009 23:04:58 GMT
Server Microsoft-IIS/6.0
X-Powered-By ASP.NET
X-AspNet-Version 2.0.50727
X-AspNetMvc-Version 1.0
Content-Encoding gzip
Cache-Control public, max-age=300
Expires Thu, 16 Jul 2009 23:04:59 GMT <<<<<<<<< This is wrong
Last-Modified Thu, 16 Jul 2009 23:04:55 GMT
Vary *
Content-Type text/html; charset=utf-8
Content-Length 575
当我将其添加到呈现 FileStreamResult 结果(该结果发送该页面的图像)的控制器操作时,我得到以下
Connection close
Date Thu, 16 Jul 2009 23:04:59 GMT
Server Microsoft-IIS/6.0
X-Powered-By ASP.NET
X-AspNet-Version 2.0.50727
Cache-Control public, max-age=300
Expires Thu, 16 Jul 2009 23:09:58 GMT <<<<<<<<< This is right
Last-Modified Thu, 16 Jul 2009 23:04:58 GMT
Vary *
但是, Last-Modified 在主页请求和图像请求之间进行处理。
在我看来,图像是正确的,因为 Expires 标头是 Last-Modified + max-age,但在主页请求中,Expires 标头与 Last-Modified 相同。 我需要两者都是 Last-Modified + max-age...
这里出了什么问题,是某个地方的错误吗?
干杯 安东尼
I'm using asp.net MVC with output caching (the OutputCache attribute) on some of my controller methods and am getting some really weird results in the HTTP headers.
When I add the attribute to the controller action that handles the main page view. the following header is produced:
Date Thu, 16 Jul 2009 23:04:58 GMT
Server Microsoft-IIS/6.0
X-Powered-By ASP.NET
X-AspNet-Version 2.0.50727
X-AspNetMvc-Version 1.0
Content-Encoding gzip
Cache-Control public, max-age=300
Expires Thu, 16 Jul 2009 23:04:59 GMT <<<<<<<<< This is wrong
Last-Modified Thu, 16 Jul 2009 23:04:55 GMT
Vary *
Content-Type text/html; charset=utf-8
Content-Length 575
But when I add it to the controller action that renders a FileStreamResult result that sends down an image for that page, I get the following
Connection close
Date Thu, 16 Jul 2009 23:04:59 GMT
Server Microsoft-IIS/6.0
X-Powered-By ASP.NET
X-AspNet-Version 2.0.50727
Cache-Control public, max-age=300
Expires Thu, 16 Jul 2009 23:09:58 GMT <<<<<<<<< This is right
Last-Modified Thu, 16 Jul 2009 23:04:58 GMT
Vary *
You will note that there is a difference in the way that the Expires & Last-Modified is treated between the main page request and the image request.
To my minds eye the image one is correct because the Expires header is Last-Modified + max-age, but in the main page request, the Expires header is the same as the Last-Modified. I need both to be Last-Modified + max-age...
Whats gone wrong here, is it a bug somewhere??
Cheers
Anthony
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论