`
touch_mai
  • 浏览: 38980 次
  • 性别: Icon_minigender_1
  • 来自: 北京
最近访客 更多访客>>
社区版块
存档分类
最新评论

“Cache-control”常见的取值有private、no-cache、max-age、must-revalidate等

阅读更多

网页的缓存是由HTTP消息头中的“Cache-control”来控制的,常见的取值有private、no-cache、max-age、must-revalidate等,默认为private。其作用根据不同的重新浏览方式分为以下几种情况:
(1) 打开新窗口
如果指定cache-control的值为private、no-cache、must-revalidate,那么打开新窗口访问时都会重新访问服务器。而如果指定了max-age值,那么在此值内的时间里就不会重新访问服务器,例如:
Cache-control: max-age=5
表示当访问此网页后的5秒内再次访问不会去服务器
(2) 在地址栏回车
如果值为private或must-revalidate(和网上说的不一样),则只有第一次访问时会访问服务器,以后就不再访问。如果值为no-cache,那么每次都会访问。如果值为max-age,则在过期之前不会重复访问。
(3) 按后退按扭
如果值为private、must-revalidate、max-age,则不会重访问,而如果为no-cache,则每次都重复访问
(4) 按刷新按扭
无论为何值,都会重复访问
当指定Cache-control值为“no-cache”时,访问此页面不会在Internet临时文章夹留下页面备份。
另外,通过指定“Expires”值也会影响到缓存。例如,指定Expires值为一个早已过去的时间,那么访问此网时若重复在地址栏按回车,那么每次都会重复访问:
Expires: Fri, 31 Dec 1999 16:00:00 GMT

在ASP中,可以通过Response对象的Expires、ExpiresAbsolute属性控制Expires值;通过Response对象的CacheControl属性控制Cache-control的值,例如:
Response.ExpiresAbsolute = #2000-1-1# ' 指定绝对的过期时间,这个时间用的是服务器当地时间,会被自动转换为GMT时间
Response.Expires = 20  ' 指定相对的过期时间,以分钟为单位,表示从当前时间起过多少分钟过期。
Response.CacheControl = "no-cache"
Expires值是可以通过在Internet临时文件夹中查看临时文件的属性看到的,
分享到:
评论

相关推荐

    Cache-control使用Cache-control:private学习笔记

    网页缓存由 HTTP消息头中的Cache-control控制,常见取值有private、no-cache、max-age、must- revalidate等,默认为private

    request的使用.txt

    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。各个消息中的指令含义...

    浅析HTTP消息头网页缓存控制以及header常用指令介绍

    网页的缓存是由HTTP消息头中的“Cache-control”来控制的,常见的取值有private、no-cache、max-age、must-revalidate等,默认为private。其作用根据不同的重新浏览方式分为以下几种情况:(1) 打开新窗口值为...

    为何要小心Nginx的add_header指令详解

    前言 大家都知道,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

    php后退一页表单内容保存实现方法

    网页的缓存是由HTTP消息头中的“Cache-control”来控制的,常见的取值有private、no- cache、max-age、must-revalidate等,默认为private。其作用根据不同的重新浏览方式分为以下几种情况: (1) 打开新窗口 值为...

    用PHP程序实现支持页面后退的两种方法

    第一,使用Header方法设置消息头Cache-control QUOTE: header(‘Cache-control: private, must-revalidate’); //支持页面回跳 第二,使用session_cache_limiter方法 QUOTE: //注意要写在session_start方法之前 ...

    让PHP支持页面回退的两种方法

    第一,使用Header方法设置消息头Cache-control header(‘Cache-control: private, must-revalidate’); //支持页面回跳  第二,使用session_cache_limiter方法 //注意要写在session_start方法之前 session_...

    让PHP支持页面回退的两种方法[转]

    第一,使用Header方法设置消息头Cache-control header(‘Cache-control: private, must-revalidate’); //支持页面回跳  第二,使用session_cache_limiter方法 //注意要写在session_start方法之前 session_...

    javascript 经典代码大全

    <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">

    fastify-disablecache:固定插件以禁用客户端缓存

    Cache-Control: no-store, no-cache, must-revalidate, proxy-revalidate Pragma: no-cache Expires: 0 您可以在阅读有关上这些响应标头的更多信息。 创建此插件的原因是,需要一种简便的方法来禁用客户端缓存,...

    利用php实现禁用IE和火狐的缓存问题

    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″> 还可以用...

    PHPExecl.tar.gz

    header('Cache-Control: max-age=0'); // If you're serving to IE 9, then the following may be needed header('Cache-Control: max-age=1'); // If you're serving to IE over SSL, then the following may be ...

    http-cache-semantics:JavaScript中的RFC 7234。 解析HTTP标头以正确计算响应的可缓存性,即使在复杂情况下也是如此

    它还实现了 ,实现了stale-if-error和stale-while-revalidate 。 它知道许多棘手的细节,例如Vary标头,代理重新验证和经过身份验证的响应。用法HTTP响应的可缓存性取决于请求的方式,因此创建策略需要同时request...

    PHP提交表单失败后如何保留已经填写的信息

    header('Cache-control: private, must-revalidate'); //支持页面回跳 2.使用session_cache_limiter方法。 PHP代码如下: session_cache_limiter('private, must-revalidate'); //要写在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

    html页面中常用的一些小方法整理

    meta http-equiv=Cache-Control content=no-cache,must-revalidate> <meta http-equiv=expires content=Wed,26 Feb 1978 08:21:57 GMT > 如何用JQuery的ajax跳转,可以这样清理 //ajax请求不缓存 $....

    resource-freshness:关于在重新验证过期的上下文中使用HTTP标头字段的提案(RFC5861)

    此标头的目的是帮助网站管理员针对给定资源优化max-age和stale-while-revalidate的值。 Resource-Freshness标头将报告原始的最大寿命值,重新验证时的原始值以及资产的当前寿命。 例子: 资源新鲜度:max-age = ...

    react+django清除浏览器缓存的几种方法小结

    META HTTP-EQUIV=Cache-Control CONTENT=no-cache, must-revalidate> <META HTTP-EQUIV=expires CONTENT=0> 二. 清理表单的方法 <body onLoad=[removed]document.yourFormName.reset()> 其实form...

Global site tag (gtag.js) - Google Analytics