header(头域)中缓存设置的详解(关于Cache-control和Pragma)
来源:互联网 发布:淘宝亏本冲销量骗局 编辑:程序博客网 时间:2024/05/22 00:32
首先分享一下CI中文件强制下载时的header设置。
if (strpos($_SERVER['HTTP_USER_AGENT'], "MSIE") !== FALSE){header('Content-Type: "'.$mime.'"');header('Content-Disposition: attachment; filename="'.$filename.'"');header('Expires: 0');header('Cache-Control: must-revalidate, post-check=0, pre-check=0');header("Content-Transfer-Encoding: binary");header('Pragma: public');header("Content-Length: ".strlen($data));}else{header('Content-Type: "'.$mime.'"');header('Content-Disposition: attachment; filename="'.$filename.'"');header("Content-Transfer-Encoding: binary");header('Expires: 0');header('Pragma: no-cache');header("Content-Length: ".strlen($data));}其他的都比较好理解,主要是关于Cache-control和Pragma的设置让人比较迷惑。
关于Cache-Control的must-revalidate:强制页面不缓存,作用与no-cache相同,但更严格,强制意味更明显。详细作用请参考:http://hi.baidu.com/chenleibupt/blog/item/9627bec6932e5a179c163df2.html
关于post-check和pre-check:Internet Explorer 5对于HTTP头信息使用两种新的时间间隔指示:pre-check 和post-check。pre-check扩展名定义了这样一段时间间隔(以秒记):即在这段时间间隔之后,一个对象在显示给用户之前应被选中进行更新。选中对象也可以发生在该对象已经显示给用户之后,但是,要保证在用户下次想要看这个对象时,被高速缓存起来的副本是更新过的。post-check扩展名定义了这样一段时间间隔(以秒记):即在这段时间之后,在显示给用户之前,该对象被选中进行更新。即post-check=0,pre-check=0是IE5.0才有的防cache声明。(参考自http://bbs.chinaunix.net/thread-704320-1-1.html和http://blog.sina.com.cn/s/blog_5595d51401000b23.html)
关于Pragma:no-cache,跟Cache-Control: no-cache相同。Pragma: no-cache兼容http 1.0 ,Cache-Control: no-cache是http 1.1提供的。因此,Pragma: no-cache可以应用到http 1.0 和http 1.1,而Cache-Control: no-cache只能应用于http 1.1.
关于Pragma:public 作用未知,还请阅读本篇文章的各位大侠给予解释。
- header(头域)中缓存设置的详解(关于Cache-control和Pragma)
- header(头域)中缓存设置的详解(关于Cache-control和Pragma)
- 使用header头设置缓存控制头Cache-control
- cache-control和pragma的区别
- Express 中设置缓存Cache-control的maxAge
- 设置http响应头Cache-Control及Pragma,增加CDN cache命中率
- 关于header("Cache-control: private")
- 浏览器缓存相关的HTTP控制头(Last-Modified/Etag/Expires/Cache-Control)详解
- HTTP头 Pragma:no-cache 缓存来源
- 关于php的 header("Cache-control: private");用法~
- HTTP消息头中的“Cache-control”控制网页的缓存
- Nginx 关于http中Cache-Control详解
- response.setHeader里的cache-control和pragma的区别
- php中header函数参数的Cache-control的使用方法
- 网站header头信息中Cache-Control max-age=0是什么意思?
- http header cache-control (request和response区别)
- 关于信息头Cache-Control的那些事儿
- nignx中Cache-Control标头和OutputCache的使用介绍
- TChart的使用
- 做题笔记之---多项式乘法
- 一位码农的人生自述(二十一)------学习
- NPF driver 问题
- VC的内存泄漏检测工具Visual Leak Detector
- header(头域)中缓存设置的详解(关于Cache-control和Pragma)
- APP开发注重用户体验
- ZT 经营自己
- Map.Entry 和 Map.entrySet() 遍历hashMap,hashTable
- 网络编程中如何为I/O操作设置超时
- 抱怨随笔
- ubuntu12.04安装中文输入法(ibus)和开机自动启动ibus应用
- PHP页面跳转
- android中用Spannable在TextView中设置超链接、颜色、字体