3 set_include_path(get_include_path() . PATH_SEPARATOR . realpath(dirname(__FILE__) . '/../../min/lib'));
4 require 'HTTP/ConditionalGet.php';
6 // emulate regularly updating document
8 $lastModified = round(time()/$every)*$every - $every;
10 $cg = new HTTP_ConditionalGet(array(
11 'lastModifiedTime' => $lastModified
13 if ($cg->cacheIsValid) {
20 $title = 'Last-Modified is known : add Content-Length';
22 <p>Here, like <a href="./">the first example</a>, we know the Last-Modified time,
23 but we also want to set the Content-Length to increase cacheability and allow
24 HTTP persistent connections. Instead of sending headers immediately, we first
25 generate our content, then use <code>setContentLength(strlen($content))</code>
26 to add the header. Then finally call <code>sendHeaders()</code> and send the
28 <p><strong>Note:</strong> This is not required if your PHP config buffers all
29 output and your script doesn\'t do any incremental flushing of the output
30 buffer. PHP will generally set Content-Length for you if it can.</p>
31 <p>This script emulates a document that changes every ' .$every. ' seconds.
32 <br>This is version: ' . date('r', $lastModified) . '</p>
35 require '_include.php';
36 $content = get_content(array(
38 ,'explain' => $explain
41 $cg->setContentLength(strlen($content));
43 send_slowly($content);