php知识点3-HTTP 头部-Cache-Control
2016-07-12 13:46
302 查看
1.概述
Cache-control用于控制HTTP缓存(在HTTP/1.0中可能部分没实现,仅仅实现了Pragma: no-cache)
2.例子
Cache-Control: cache-directive
cache-directive可以为以下:
request时用到:
no-cache
no-store
max-age = delta-seconds
max-stale = delta-seconds
min-fresh = delta-seconds
no-transform"
only-if-cached"
cache-extension"
response时用到:
public
private = <> field-name <">
no-cache = field-name
no-store"
no-transform
must-revalidate
proxy-revalidate
max-age = delta-seconds
s-maxage = delta-seconds
cache-extension"
3.分析
Cache-control: max-age=5
表示当访问此网页后的5秒内再次访问不会去服务器
Cache-Control: no-cache:这个很容易让人产生误解,使人误以为是响应不被缓存。
实际上Cache-Control: no-cache是会被缓存的,只不过每次在向客户端(浏览器)提供响应数据时,
缓存都要向服务器评估缓存响应的有效性。
Cache-Control: no-store:这个才是响应不被缓存的意思。
Cache-control用于控制HTTP缓存(在HTTP/1.0中可能部分没实现,仅仅实现了Pragma: no-cache)
2.例子
Cache-Control: cache-directive
cache-directive可以为以下:
request时用到:
no-cache
no-store
max-age = delta-seconds
max-stale = delta-seconds
min-fresh = delta-seconds
no-transform"
only-if-cached"
cache-extension"
response时用到:
public
private = <> field-name <">
no-cache = field-name
no-store"
no-transform
must-revalidate
proxy-revalidate
max-age = delta-seconds
s-maxage = delta-seconds
cache-extension"
3.分析
Cache-control: max-age=5
表示当访问此网页后的5秒内再次访问不会去服务器
Cache-Control: no-cache:这个很容易让人产生误解,使人误以为是响应不被缓存。
实际上Cache-Control: no-cache是会被缓存的,只不过每次在向客户端(浏览器)提供响应数据时,
缓存都要向服务器评估缓存响应的有效性。
Cache-Control: no-store:这个才是响应不被缓存的意思。
相关文章推荐
- 一个关于if else容易迷惑的问题
- PHP5.2.*防止Hash冲突拒绝服务攻击的Patch
- 深入理解PHP之匿名函数
- JSP/PHP基于Ajax的分页功能实现
- 关于PHP通过PDO用中文条件查询MySQL的问题。
- 什么是设计模式
- PHP数据库长连接mysql_pconnect的细节
- Php Installing An Expansion
- rem : web app适配的秘密武器
- jquery高级应用之Deferred对象
- 关于浮动与清除浮动,你应该知道的
- 数组reduce方法的高级技巧
- php7 读取php.ini[4]
- PHP+Apache在Windows 9x下的安装和配置
- IIS 6 的 PHP 最佳配置方法
- 安装Apache和PHP的一些补充
- Linux Apache+MySQL+PHP
- 建立Apache+PHP+MySQL数据库驱动的动态网站