客户端从服务器请求数据经历如下基本步骤:
1、如果请求命中本地缓存则从本地缓存中获取一个对应资源的"copy";
2、检查这个"copy"是否fresh,是则直接返回,否则继续向服务器转发请求。
3、服务器接收到请求,然后判断资源是否变更,是则返回新内容,否则返回304,未变更。
4、客户端更新本地缓存。
no-cache的作用是:强制客户端跳过步骤2,直接向服务器发送请求。也就是说每次请求都必须向服务器发送。
must-revalidate:作用与no-cache相同,但更严格,强制意味更明显。但
这只是理论上的描述,根据我在ff6上的测试,它几乎不起作用:只要请求的频率加快到一定程度,服务器就接收不到请求。
no-store:缓存将不存储response,包括header和body。测试结果表明,除每次请求都必发送到服务器外,响应代码均是200,且request并没有发送"If-Modified-Since"和"If-None-Match"头,这意味着缓存的确没有存储response。
以上三者都是要求客户端每次请求都必须到服务器进行revalidate,此功能还可以通过max-age实现:
Cache-Control:max-age=0
测试结果证明了这一点,每次都请求了服务器,且状态码是304。
<META HTTP-EQUIV="Cache-control" CONTENT="no-cache">
这种设置方式大部分服务器不支持,额外的解析成本、只支持html文件等原因造成的结果是,它基本上是无效的。
分享到:
相关推荐
Cache-Control: no-store, no-cache, must-revalidate, proxy-revalidate Pragma: no-cache Expires: 0 您可以在阅读有关上这些响应标头的更多信息。 创建此插件的原因是,需要一种简便的方法来禁用客户端缓存,...
请求时的缓存指令包括no-cache、no-store、max-age、max-stale、min-fresh、only-if-cached,响应消息中的指令包括public、private、no-cache、no-store、no-transform、must-revalidate、proxy-revalidate、max-age...
前言 大家都知道,nginx配置文件通过使用add_header指令来设置response header。 昨天无聊用curl查看一个站点的...cache-control: max-age=3, must-revalidate last-modified: Thu, 07 Feb 2019 03:54:54 GMT X-Cach
网页缓存由 HTTP消息头中的Cache-control控制,常见取值有private、no-cache、max-age、must- revalidate等,默认为private
header('Cache-Control: cache, must-revalidate'); // HTTP/1.1 header('Pragma: public'); // HTTP/1.0 $objWriter = new PHPExcel_Writer_Excel5($objPHPExcelWrite); $objPHPExcelWrite->getActiveSheet()->...
我可以缓存吗? CachePolicy告诉用户何时可以从缓存中重用响应,并考虑了用户代理和共享缓存的规则。 它还实现了 ,实现了stale-if-error和stale-while-revalidate 。 它知道许多棘手的细节,例如Vary标头,代理重新...
第一,使用Header方法设置消息头Cache-control QUOTE: header(‘Cache-control: private, must-revalidate’); //支持页面回跳 第二,使用session_cache_limiter方法 QUOTE: //注意要写在session_start方法之前 ...
本文实例讲述了YII框架http缓存...header('Cache-Control: no-store, no-cahe, must-revalidate'); //ie专用 header('Cache-Control: post-chedk=0, pre-check=0', false); //for HTTP/1.0 header('Pragma: no-cache
PHPExcel是相当强大的 MS Office Excel 文档... ////header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); ////header("Pragma: no-cache"); ////$objWriter->save('php://output'); ?>
在React中获取,缓存和更新异步数据的钩子 喜欢这个图书馆吗? 尝试整个 ! ,, 访问获取文档,指南,API等! 还在使用React Query v2吗? 没问题! 在此处查看v2文档: : 。 快速功能 传输/协议/后端不可知数据...
META HTTP-EQUIV=”Cache-Control” CONTENT=”no-cache,no-store, must-revalidate”> <META HTTP-EQUIV=”pragma” CONTENT=”no-cache”> <META HTTP-EQUIV=”expires” CONTENT=”0″> 还可以用...
(curl -H "Cache-Control: no-cache, no-store, must-revalidate" https://raw.githubusercontent.com/ygnr/mac-setup/master/setup.sh)安装Vscode扩展cd $HOME/Codechmod +x ./vscode/mac-setup/install.sh./vscode...
must-revalidate'); header('Pragma: public'); header('Content-Length: ' . filesize($file)); readfile($file); exit; } ?> header content-type 参数列表 Content-type 的说明: 'hqx' -> '...
分享给大家供大家参考。具体实现方法如下: function downloadFile($file){ $file_name = $file;... header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Cache
header(‘Cache-Control: no-cache, must-revalidate’); header(‘Pragma: no-cache’); ?> 您可能感兴趣的文章:PHP使用header()输出图片缓存实例PHP输出缓存ob系列函数详解基于PHP输出缓存(output_b
网页的缓存是由HTTP消息头中的“Cache-control”来控制的,常见的取值有private、no-cache、max-age、must-revalidate等,默认为private。其作用根据不同的重新浏览方式分为以下几种情况:(1) 打开新窗口值为...
header(“Cache-Control: no-cache, must-revalidate”); header(“Pramga: no-cache”); 这对于某些页面来说是很有用的,例如:验证码,因为每次生成的验证码必须不同,否则验证码就没有任何意义了,这就可以用...
具体如下: ...header('Cache-Control: no-cache, must-revalidate'); header('Expires: Fri, 14 Mar 1980 20:53:00 GMT'); header('Last-Modified: ' . date('r')); header('Pragma: no-cache');
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate"> <META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT"> 或者<META HTTP-EQUIV="expires" CONTENT="0">