php知识点3-HTTP 头部-Cache-Control



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:这个才是响应不被缓存的意思。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值