uTools-Manuals/docs/php/session_cache_limiter.html
2019-04-28 19:00:34 +08:00

181 lines
7.0 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>读取/设置缓存限制器</title>
</head>
<body class="docs"><div id="layout">
<div id="layout-content"><div id="function.session-cache-limiter" class="refentry">
<div class="refnamediv">
<h1 class="refname">session_cache_limiter</h1>
<p class="verinfo">(PHP 4 &gt;= 4.0.3, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">session_cache_limiter</span> &mdash; <span class="dc-title">读取/设置缓存限制器</span></p>
</div>
<div class="refsect1 description" id="refsect1-function.session-cache-limiter-description">
<h3 class="title">说明</h3>
<div class="methodsynopsis dc-description">
<span class="methodname"><strong>session_cache_limiter</strong></span>
([ <span class="methodparam"><span class="type">string</span> <code class="parameter">$cache_limiter</code></span>
] ) : <span class="type">string</span></div>
<p class="para rdfs-comment">
<span class="function"><strong>session_cache_limiter()</strong></span> 返回当前缓存限制器的名称。
</p>
<p class="para">
缓存限制器定义了向客户端发送的 HTTP 响应头中的缓存控制策略。
客户端或者代理服务器通过检测这个响应头信息来
确定对于页面内容的缓存规则。
设置缓存限制器为 <em>nocache</em> 会进制客户端或者代理服务器缓存内容,
<em>public</em> 表示允许客户端或代理服务器缓存内容,
<em>private</em> 表示允许客户端缓存,
但是不允许代理服务器缓存内容。
</p>
<p class="para">
<em>private</em> 模式下, 包括 <span class="productname">Mozilla</span>
在内的一些浏览器可能无法正确处理 Expire 响应头,
通过使用 <em>private_no_expire</em> 模式可以解决这个问题:在这种模式下,
不会向客户端发送 <em>Expire</em> 响应头。
</p>
<p class="para">
设置为 <em>&#039;&#039;</em> 可以关闭
自动发送缓存策略响应头的功能。
</p>
<p class="para">
请求开始的时候,缓存限制器会被重置为默认值,并且存储在
<a href="session.configuration.html#ini.session.cache-limiter" class="link">session.cache_limiter</a>
配置项中。
因此,如果要设置缓存限制器,对于每个请求,
都需要在调用 <span class="function"><a href="session_start.html" class="function">session_start()</a></span> 函数之前,
调用 <span class="function"><strong>session_cache_limiter()</strong></span> 函数来进行设置。
</p>
</div>
<div class="refsect1 parameters" id="refsect1-function.session-cache-limiter-parameters">
<h3 class="title">参数</h3>
<p class="para">
<dl>
<dt>
<code class="parameter">cache_limiter</code></dt>
<dd>
<p class="para">
如果指定了 <code class="parameter">cache_limiter</code> 参数,
将使用指定值作为缓存限制器的值。
</p>
<table class="doctable table">
<caption><strong>可选的值</strong></caption>
<thead>
<tr>
<th></th>
<th>发送的响应头</th>
</tr>
</thead>
<tbody class="tbody">
<tr>
<td><em>public</em></td>
<td>
<div class="example-contents">
<div class="headercode"><pre class="headercode">Expires根据 session.cache_expire 的设定计算得出)
Cache-Control public, max-age=(根据 session.cache_expire 的设定计算得出)
Last-Modified会话最后保存时间</pre>
</div>
</div>
</td>
</tr>
<tr>
<td><em>private_no_expire</em></td>
<td>
<div class="example-contents">
<div class="headercode"><pre class="headercode">Cache-Control: private, max-age=(根据 session.cache_expire 的设定计算得出), pre-check=(根据 session.cache_expire 的设定计算得出)
Last-Modified: (会话最后保存时间)</pre>
</div>
</div>
</td>
</tr>
<tr>
<td><em>private</em></td>
<td>
<div class="example-contents">
<div class="headercode"><pre class="headercode">Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: private, max-age=(根据 session.cache_expire 的设定计算得出), pre-check=(根据 session.cache_expire 的设定计算得出)
Last-Modified: (会话最后保存时间)</pre>
</div>
</div>
</td>
</tr>
<tr>
<td><em>nocache</em></td>
<td>
<div class="example-contents">
<div class="headercode"><pre class="headercode">Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache</pre>
</div>
</div>
</td>
</tr>
</tbody>
</table>
</dd>
</dl>
</p>
</div>
<div class="refsect1 returnvalues" id="refsect1-function.session-cache-limiter-returnvalues">
<h3 class="title">返回值</h3>
<p class="para">
返回当前所用的缓存限制器名称。
</p>
</div>
<div class="refsect1 examples" id="refsect1-function.session-cache-limiter-examples">
<h3 class="title">范例</h3>
<p class="para">
<div class="example" id="example-5830">
<p><strong>Example #1 <span class="function"><strong>session_cache_limiter()</strong></span> 示例</strong></p>
<div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">/*&nbsp;设置缓存限制器为&nbsp;'private'&nbsp;*/<br /><br /></span><span style="color: #0000BB">session_cache_limiter</span><span style="color: #007700">(</span><span style="color: #DD0000">'private'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$cache_limiter&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">session_cache_limiter</span><span style="color: #007700">();<br /><br />echo&nbsp;</span><span style="color: #DD0000">"The&nbsp;cache&nbsp;limiter&nbsp;is&nbsp;now&nbsp;set&nbsp;to&nbsp;</span><span style="color: #0000BB">$cache_limiter</span><span style="color: #DD0000">&lt;br&nbsp;/&gt;"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
</div>
</div>
</p>
</div>
<div class="refsect1 seealso" id="refsect1-function.session-cache-limiter-seealso">
<h3 class="title">参见</h3>
<p class="para">
<ul class="simplelist">
<li class="member"><a href="session.configuration.html#ini.session.cache-limiter" class="link">session.cache_limiter</a></li>
</ul>
</p>
</div>
</div></div></div></body></html>