ASP.NET MVC:OutputCache 和 http 标头 - Cache-Control

发布于 2024-07-26 12:25:16 字数 1034 浏览 3 评论 0原文

我刚刚开始在一些控制器操作上使用 OutputCache,但没有完全得到我期望的响应。

基本上我已经设置了 Location = OutputCacheLocation.Any 并且 http 标头如下:

Server              ASP.NET Development Server/9.0.0.0
Date                Wed, 15 Jul 2009 02:14:21 GMT
X-AspNet-Version    2.0.50727
X-AspNetMvc-Version 1.0
Content-Encoding    gzip
Cache-Control       private, max-age=3600
Expires             Wed, 15 Jul 2009 02:14:21 GMT
Last-Modified       Wed, 15 Jul 2009 02:14:20 GMT
Vary                *
Content-Type        text/html; charset=utf-8
Content-Length      640
Connection          Close

现在,如果我的解释正确,则将 Cache-Control 部分设置为私有意味着它将仅缓存在客户端上。 我还需要在任何代理上缓存。

我本来期望通过设置 OutputCacheLocation.Any Cache-Control 会类似于“public, max-age=3600”。 据我所知,私有意味着它只会缓存在客户端上,而不是由“任何”(即代理 - 请参阅http://msdn.microsoft.com/en-us/library/system.web.httpcacheability.aspx)。

有任何想法吗?

干杯 安东尼

I have just started using OutputCache on some of my controller actions and I am not quite getting the response I would expect.

Basically I have set Location = OutputCacheLocation.Any and the http header is as follows:

Server              ASP.NET Development Server/9.0.0.0
Date                Wed, 15 Jul 2009 02:14:21 GMT
X-AspNet-Version    2.0.50727
X-AspNetMvc-Version 1.0
Content-Encoding    gzip
Cache-Control       private, max-age=3600
Expires             Wed, 15 Jul 2009 02:14:21 GMT
Last-Modified       Wed, 15 Jul 2009 02:14:20 GMT
Vary                *
Content-Type        text/html; charset=utf-8
Content-Length      640
Connection          Close

Now if my interpretation is correct the Cache-Control part being set to private means that it will only be cached on the client. I need to also be cached on any proxy.

I would have expected that by setting OutputCacheLocation.Any the Cache-Control would have been something like "public, max-age=3600". As far as I know the private means it will only be cached on the client and not by "Any" (i.e. proxies - see http://msdn.microsoft.com/en-us/library/system.web.httpcacheability.aspx).

Any ideas?

Cheers
Anthony

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鹿港小镇 2024-08-02 12:25:17

请参阅上面的评论以获取解决方案

编辑

此评论被视为答案:

您是否尝试过将站点发布到 IIS 并查看标头
那里? 和开发服务器上的一样吗? –

See comments above for solution

EDIT

This comment was deemed the answer:

Have you tried publishing your site to IIS and looking at the headers
there? Is it the same as on the dev server? –

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文