错误在:System.Web.UI.Page.InitOutputCache() 或 System.Web.Mvc 中?

发布于 2024-07-27 16:41:24 字数 1391 浏览 1 评论 0原文

我在一些控制器方法上使用带有输出缓存(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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文