ASP.NET MVC:OutputCache 和 http 标头
我刚刚开始在一些控制器操作上使用 OutputCache,但没有完全得到我期望的响应。
我已将缓存时间设置为 5 分钟,并且 Expires 标头与 Last-Modified 标头(发出请求的时间)相同。
这是我当前得到的标题:
Date Thu, 16 Jul 2009 06:35:07 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 06:35:06 GMT
Last-Modified Thu, 16 Jul 2009 06:35:03 GMT
Vary *
Content-Type text/html; charset=utf-8
Content-Length 575
这是我期望的标题:
Date Thu, 16 Jul 2009 06:35:07 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 06:40:06 GMT
Last-Modified Thu, 16 Jul 2009 06:35:03 GMT
Vary *
Content-Type text/html; charset=utf-8
Content-Length 575
关于为什么要这样做的任何想法?
干杯 安东尼
I have just started using OutputCache on some of my controller actions and I am not quite getting the response I would expect.
I have set the cache time to 5 minutes and the Expires header is coming up the same as the Last-Modified header which is the time that the request was made.
This is the header I am currently getting:
Date Thu, 16 Jul 2009 06:35:07 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 06:35:06 GMT
Last-Modified Thu, 16 Jul 2009 06:35:03 GMT
Vary *
Content-Type text/html; charset=utf-8
Content-Length 575
This is the header I would expect:
Date Thu, 16 Jul 2009 06:35:07 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 06:40:06 GMT
Last-Modified Thu, 16 Jul 2009 06:35:03 GMT
Vary *
Content-Type text/html; charset=utf-8
Content-Length 575
Any ideas on why it would be doing this?
Cheers
Anthony
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
max-age
优先(来自 RFC 2616):所以客户端应该按照你的预期使用缓存的版本。
max-age
takes precedence (from RFC 2616):So the client should use the cached version as you expect.