<!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 last modification</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.http-cache-etag.html">http_cache_etag</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.http-chunked-decode.html">http_chunked_decode</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-last-modified" class="refentry"> <div class="refnamediv"> <h1 class="refname">http_cache_last_modified</h1> <p class="verinfo">(PECL pecl_http >= 0.1.0)</p><p class="refpurpose"><span class="refname">http_cache_last_modified</span> — <span class="dc-title">Caching by last modification</span></p> </div> <div class="refsect1 description" id="refsect1-function.http-cache-last-modified-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">bool</span> <span class="methodname"><strong>http_cache_last_modified</strong></span> ([ <span class="methodparam"><span class="type">int</span> <code class="parameter">$timestamp_or_expires</code></span> ] )</div> <p class="para rdfs-comment"> Attempts to cache the sent entity by its last modification date. </p> <p class="para"> If the supplied argument is greater than 0, it is handled as timestamp and will be sent as date of last modification. If it is 0 or omitted, the current time will be sent as <em>Last-Modified</em> date. If it's negative, it is handled as expiration time in seconds, which means that if the requested last modification date is not between the calculated timespan, the <em>Last-Modified</em> header is updated and the actual body will be sent. </p> <p class="para"> A log entry will be 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> </div> <div class="refsect1 parameters" id="refsect1-function.http-cache-last-modified-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">timestamp_or_expires</code></em></span> <dd> <p class="para"> Unix timestamp </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.http-cache-last-modified-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-last-modified-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-4359"> <p><strong>Example #1 A <span class="function"><strong>http_cache_last_modified()</strong></span> example</strong></p> <div class="example-contents"><p> Caching for 5 seconds. </p></div> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br />http_cache_last_modified</span><span style="color: #007700">(-</span><span style="color: #0000BB">5</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"%s\n"</span><span style="color: #007700">, </span><span style="color: #0000BB">http_date</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-last-modified-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.http-cache-etag.html" class="function" rel="rdfs-seeAlso">http_cache_etag()</a> - Caching by 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="function.http-cache-etag.html">http_cache_etag</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.http-chunked-decode.html">http_chunked_decode</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>