ASP.NET MVC:OutputCache 和 http 标头 - Cache-Control
我刚刚开始在一些控制器操作上使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参阅上面的评论以获取解决方案
编辑
此评论被视为答案:
See comments above for solution
EDIT
This comment was deemed the answer: