nginx 配置缓存 no-cache no-store
2011-05-24 15:53
375 查看
根据文档,可以使用 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,如果要立即生效,最好是修改一下那个页面,让浏览器知道页面已经被更新,好重新获取页面内容。
该指令会在响应的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,如果要立即生效,最好是修改一下那个页面,让浏览器知道页面已经被更新,好重新获取页面内容。
相关文章推荐
- nginx 配置缓存 no-cache no-store
- 配置Nginx出现No input file specified.
- Nginx配置缓存静态资源
- nginx配置遭遇No input file specified问题
- 官方参考Nginx 配置Wordpress wp Super Cache缓存插件
- nginx反向代理之缓存,负载均衡,动静分离的配置详解
- nginx静态资源缓存策略配置
- Nginx缓存、压缩配置
- Nginx学习历程_5_Nginx对于静态文件的缓存配置
- 反向代理中的Nginx.conf缓存配置
- 14 nginx 中配置 expires缓存提升网站负载
- Nginx 配置 HTTP 强缓存
- 关于页面缓存的Cache-Control之no-store
- nginx日志切割,日志格式,静态文件不记录日志,配置缓存
- ubuntu下配置nginx支持phpt(unix:/var/run/php5-fpm.sock failed (2: No such file or directory) )
- nginx利用lua实现nginx反向代理proxy_store缓存文件自删除
- nginx设置不使用缓存 add_header Cache-Control no-cache
- Nginx缓存配置以及nginx ngx_cache_purge模块的使用
- 夺命雷公狗---memcache NO:05 分布式的内存对象缓存系统的配置
- 配置Nginx支持php,出现No input file specified错误的解决方法