<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>OurApache &#187; Cache-control</title>
	<atom:link href="http://ourapache.com/archives/tag/cache-control/feed" rel="self" type="application/rss+xml" />
	<link>http://ourapache.com</link>
	<description>我们致力于一个Apache知识的分享网站</description>
	<lastBuildDate>Tue, 13 Apr 2010 05:18:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>header中的Cache-control参数说明</title>
		<link>http://ourapache.com/archives/187</link>
		<comments>http://ourapache.com/archives/187#comments</comments>
		<pubDate>Fri, 27 Feb 2009 02:46:50 +0000</pubDate>
		<dc:creator>OurApache</dc:creator>
				<category><![CDATA[HTTP相关知识]]></category>
		<category><![CDATA[Cache-control]]></category>
		<category><![CDATA[header]]></category>
		<category><![CDATA[缓存]]></category>

		<guid isPermaLink="false">http://www.ourapache.com/?p=187</guid>
		<description><![CDATA[    网页的缓存是由HTTP消息头中的“Cache-control”来控制的，常见的取值有private、no-cache、max-age、must-revalidate等，默认为private。]]></description>
			<content:encoded><![CDATA[<p>    网页的缓存是由HTTP消息头中的“<a href="http://ourapache.com/archives/tag/cache-control" class="st_tag internal_tag" rel="tag" title="标签 Cache-control 下的日志">Cache-control</a>”来控制的，常见的取值有private、no-cache、max-age、must-revalidate等，默认为private。其作用根据不同的重新浏览方式分为以下几种情况：</p>
<p><strong>（1） 打开新窗口</strong><br />
    值为private、no-cache、must-revalidate，那么打开新窗口访问时都会重新访问服务器。<br />
而如果指定了max-age值，那么在此值内的时间里就不会重新访问服务器，例如：<br />
Cache-control: max-age=5(表示当访问此网页后的5秒内再次访问不会去服务器)</p>
<p><strong>（2） 在地址栏回车</strong><br />
    值为private或must-revalidate则只有第一次访问时会访问服务器，以后就不再访问。<br />
    值为no-cache，那么每次都会访问。<br />
    值为max-age，则在过期之前不会重复访问。</p>
<p><strong>（3） 按后退按扭</strong><br />
   值为private、must-revalidate、max-age，则不会重访问，<br />
   值为no-cache，则每次都重复访问</p>
<p><strong>（4） 按刷新按扭</strong><br />
　 无论为何值，都会重复访问</p>
<p>Cache-control值为“no-cache”时，访问此页面不会在Internet临时文章夹留下页面备份。</p>
<p>另外，<strong>通过指定“Expires”值也会影响到缓存</strong>。例如，指定Expires值为一个早已过去的时间，那么访问此网时若重复在地址栏按回车，那么每次都会重复访问： Expires: Fri, 31 Dec 1999 16:00:00 GMT</p>
<p>比如：禁止页面在IE中缓存</p>
<p>http响应消息头部设置：</p>
<blockquote><p>CacheControl = no-cache<br />
Pragma=no-cache<br />
Expires = -1</p></blockquote>
<p>Expires是个好东东，如果服务器上的网页经常变化，就把它设置为-1，表示立即过期。如果一个网页每天凌晨1点更新，可以把Expires设置为第二天的凌晨1点。</p>
<p>当HTTP1.1服务器指定CacheControl = no-cache时，浏览器就不会缓存该网页。</p>
<p>旧式 HTTP 1.0 服务器不能使用 Cache-Control 标题。</p>
<p>所以为了向后兼容 HTTP 1.0 服务器，IE使用Pragma:no-cache 标题对 HTTP 提供特殊支持。</p>
<p>如果客户端通过安全连接 (https://)与服务器通讯，且服务器在响应中返回 Pragma:no-cache 标题，则 Internet Explorer不会缓存此响应。注意：Pragma:no-cache 仅当在安全连接中使用时才防止缓存，如果在非安全页中使用，处理方式与Expires:-1相同，该页将被缓存，但被标记为立即过期。</p>
<h3  class="related_post_title">相关文章</h3><ul class="related_post"><li>2009年02月27号 -- <a href="http://ourapache.com/archives/209" title="面向站长和网站管理员的Web缓存加速指南">面向站长和网站管理员的Web缓存加速指南</a></li><li>2009年02月27号 -- <a href="http://ourapache.com/archives/206" title="http header详解">http header详解</a></li><li>2009年02月27号 -- <a href="http://ourapache.com/archives/200" title="header常用指令">header常用指令</a></li><li>2009年02月27号 -- <a href="http://ourapache.com/archives/193" title="header Content-Type类型">header Content-Type类型</a></li><li>2009年02月27号 -- <a href="http://ourapache.com/archives/190" title="header Content-Disposition参数说明">header Content-Disposition参数说明</a></li><li>2009年02月25号 -- <a href="http://ourapache.com/archives/178" title="Apache缓存系统">Apache缓存系统</a></li><li>2009年02月25号 -- <a href="http://ourapache.com/archives/165" title="Apache 设置web 缓存">Apache 设置web 缓存</a></li><li>2009年02月7号 -- <a href="http://ourapache.com/archives/89" title="Apache PHP利用HTTP缓存协议原理解析及应用">Apache PHP利用HTTP缓存协议原理解析及应用</a></li></ul>
	标签：<a href="http://ourapache.com/archives/tag/cache-control" title="Cache-control" rel="tag">Cache-control</a>, <a href="http://ourapache.com/archives/tag/header" title="header" rel="tag">header</a>, <a href="http://ourapache.com/archives/category/http" title="HTTP相关知识" rel="tag">HTTP相关知识</a>, <a href="http://ourapache.com/archives/tag/%e7%bc%93%e5%ad%98" title="缓存" rel="tag">缓存</a><br />
]]></content:encoded>
			<wfw:commentRss>http://ourapache.com/archives/187/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

