<!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>Caching by ETag</title> </head> <body><div class="manualnavbar" 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)</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" id="refsect1-function.http-cache-etag-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">bool</span> <span class="methodname"><strong>http_cache_etag</strong></span> ([ <span class="methodparam"><span class="type">string</span> <code class="parameter">$etag</code></span> ] )</div> <p class="para rdfs-comment"> Attempts to cache the sent entity by its <em>ETag</em>, either supplied or generated by the hash algorithm specified by the <a href="http.configuration.html" class="link">INI setting</a> <a href="" class="link">http.etag.mode</a>. </p> <p class="para"> If the clients <em>If-None-Match</em> header matches the supplied/calculated ETag, the body is considered cached on the clients side and a <em>304 Not Modified</em> 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="" class="link">http.log.cache</a> is set and the cache attempt was successful. </p> <blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">This function may be used in conjunction with <span class="function"><a href="function.http-send-data.html" class="function">http_send_data()</a></span>, <span class="function"><a href="function.http-send-file.html" class="function">http_send_file()</a></span> and <span class="function"><a href="function.http-send-stream.html" class="function">http_send_stream()</a></span>.</span></p></blockquote> <p class="para"> If this function is used outside the http_send_*() API, it facilitates the <span class="function"><a href="function.ob-etaghandler.html" class="function">ob_etaghandler()</a></span>. </p> </div> <div class="refsect1 parameters" id="refsect1-function.http-cache-etag-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">etag</code></em></span> <dd> <p class="para"> custom <em>ETag</em> </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.http-cache-etag-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns <strong><code>FALSE</code></strong> or <em class="emphasis">exits</em> on success with <em>304 Not Modified</em> if the entity is cached. See the <a href="http.configuration.html" class="link">INI setting</a> <a href="" class="link">http.force_exit</a> for what "exits" means. </p> </div> <div class="refsect1 examples" id="refsect1-function.http-cache-etag-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-4358"> <p><strong>Example #1 A <span class="function"><strong>http_cache_etag()</strong></span> example</strong></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" id="refsect1-function.http-cache-etag-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.http-cache-last-modified.html" class="function" rel="rdfs-seeAlso">http_cache_last_modified()</a> - Caching by last modification</span></li> <li class="member"> <span class="function"><a href="function.ob-etaghandler.html" class="function" rel="rdfs-seeAlso">ob_etaghandler()</a> - ETag output handler</span></li> <li class="member"> <span class="function"><a href="function.http-match-etag.html" class="function" rel="rdfs-seeAlso">http_match_etag()</a> - Match ETag</span></li> <li class="member">the <a href="class.httpresponse.html" class="link"> <a href="class.httpresponse.html" class="classname">HttpResponse</a></a> class if you are using PHP 5.1.0 and above</li> </ul> </p> </div> </div><hr /><div class="manualnavbar" 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>