📄 function.http-cache-etag.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Caching by ETag</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="ref.http.html">HTTP Functions</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.http-cache-last-modified.html">http_cache_last_modified</a></div> <div class="up"><a href="ref.http.html">HTTP Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.http-cache-etag" class="refentry"> <div class="refnamediv"> <h1 class="refname">http_cache_etag</h1> <p class="verinfo">(PECL pecl_http:0.1.0-1.5.5)</p><p class="refpurpose"><span class="refname">http_cache_etag</span> — <span class="dc-title">Caching by ETag</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">bool</span> <span class="methodname"><b><b>http_cache_etag</b></b></span> ([ <span class="methodparam"><span class="type">string</span> <tt class="parameter">$etag</tt></span> ] )</div> <p class="para rdfs-comment"> Attempts to cache the sent entity by its <i>ETag</i>, either supplied or generated by the hash algorithm specified by the <a href="http.configuration.html" class="link">INI setting</a> <a href="http.configuration.html#http.configuration.etag.mode" class="link">http.etag.mode</a>. </p> <p class="para"> If the clients <i>If-None-Match</i> header matches the supplied/calculated ETag, the body is considered cached on the clients side and a <i>304 Not Modified</i> status code is issued. </p> <p class="para"> A log entry is written to the cache log if the <a href="http.configuration.html" class="link">INI setting</a> <a href="http.configuration.html#http.configuration.log.cache" class="link">http.log.cache</a> is set and the cache attempt was successful. </p> <blockquote><p><b class="note">Note</b>: <span class="simpara">This function may be used in conjunction with <a href="function.http-send-data.html" class="function">http_send_data()</a>, <a href="function.http-send-file.html" class="function">http_send_file()</a> and <a href="function.http-send-stream.html" class="function">http_send_stream()</a>.</span></p></blockquote> <p class="para"> If this function is used outside the http_send_*() API, it facilitates the <a href="function.ob-etaghandler.html" class="function">ob_etaghandler()</a>. </p> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">etag</tt></i></span> <dd> <p class="para"> custom <i>ETag</i> </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns <b><tt>FALSE</tt></b> or <em class="emphasis">exits</em> on success with <i>304 Not Modified</i> if the entity is cached. See the <a href="http.configuration.html" class="link">INI setting</a> <a href="http.configuration.html#http.configuration.force_exit" class="link">http.force_exit</a> for what "exits" means. </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example"> <p><b>Example #1 A <b>http_cache_etag()</b> example</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br />http_cache_etag</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">http_send_data</span><span style="color: #007700">(</span><span style="color: #DD0000">"data"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> </p> </div> <div class="refsect1 seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><a href="function.http-cache-last-modified.html" class="function" rel="rdfs-seeAlso">http_cache_last_modified()</a></li> <li class="member"><a href="function.ob-etaghandler.html" class="function" rel="rdfs-seeAlso">ob_etaghandler()</a></li> <li class="member"><a href="function.http-match-etag.html" class="function" rel="rdfs-seeAlso">http_match_etag()</a></li> <li class="member">the <a href="class.httpresponse.html" class="link"><b class="classname">HttpResponse</b></a> class if you are using PHP 5.1.0and above</li> </ul> </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="ref.http.html">HTTP Functions</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.http-cache-last-modified.html">http_cache_last_modified</a></div> <div class="up"><a href="ref.http.html">HTTP Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -