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 require 'HTTP/Encoder.php';
11 list($enc,) = HTTP_Encoder::getAcceptedEncoding();
13 $cg = new HTTP_ConditionalGet(array(
14 'lastModifiedTime' => $lastModified
18 if ($cg->cacheIsValid) {
23 // output encoded content
25 $title = 'ConditionalGet + Encoder';
27 <p>Using ConditionalGet and Encoder is straightforward. First impliment the
28 ConditionalGet, then if the cache is not valid, encode and send the content</p>
29 <p>This script emulates a document that changes every ' .$every. ' seconds.
30 <br>This is version: ' . date('r', $lastModified) . '</p>
32 require '_include.php';
33 $content = get_content(array(
35 ,'explain' => $explain
38 $he = new HTTP_Encoder(array(
39 'content' => get_content(array(
41 ,'explain' => $explain
46 // usually you would just $he->sendAll(), but here we want to emulate slow
49 send_slowly($he->getContent());