码迷,mamicode.com
首页 > 系统相关 > 详细

nginx 配置缓存 no-cache no-store

时间:2015-04-29 20:01:39      阅读:157      评论:0      收藏:0      [点我收藏+]

标签:nginx 配置缓存 no-cache no-store

根据文档,可以使用 expires 来完成
该指令会在响应的header信息中增加一个 Expires 和一个 Cache-Control: (如果时间是负数no-cache,反之max-age = #, # 为您指定时间的秒数)信息
如果不想缓存某个页面,可以用 expires -1; 使用这个相对于 header里面有了 Cache-Control:no-cache; 经过测试,在ie 6,8下面正常工作,F5刷新每次应答的状态码为200,但是firefox,chrome下,F5刷新依然是304,查看响应的header信息中也有 Cache-Control:no-cache,页面还是被缓存了,后来通过httpwatch查看的时候注意到里面有一个warnning,内容为 “The ‘no-cache‘ directive was used without the ‘no-store‘ directive. Using ‘no-store‘ ensures that Firefox will always re-fetch HTTP based pages and never use a previous version.”然后再nginx配置里面增加了一个 add_header Cache-Control no-store; 然后再测试,在ie6,8 ,firefox,chrmoe下都能成功缓存。进一步测试,发现只要设置了no-store,不要no-cache,甚至 expires 时间为正数时都不会有缓存了

 

另外如果先前页面已经是缓存的,设置了不缓存,也重启服务器,在ie下,用F5刷新还是返回304,除非ctrl+F5后才返回200,如果要立即生效,最好是修改一下那个页面,让浏览器知道页面已经被更新,好重新获取页面内容。


本文出自 “smile_青春” 博客,请务必保留此出处http://smileyouth.blog.51cto.com/7273768/1640423

nginx 配置缓存 no-cache no-store

标签:nginx 配置缓存 no-cache no-store

原文地址:http://smileyouth.blog.51cto.com/7273768/1640423

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!