E.g. Content from DB with update time:
list($updateTime, $content) = getDbUpdateAndContent();
$cg = new HTTP_ConditionalGet(array(
'lastModifiedTime' => $updateTime
,'isPublic' => true
));
$cg->sendHeaders();
if ($cg->cacheIsValid) {
exit();
}
echo $content;
E.g. Shortcut for the above
HTTP_ConditionalGet::check($updateTime, true); // exits if client has cache
echo $content;
E.g. Content from DB with no update time:
$content = getContentFromDB();
$cg = new HTTP_ConditionalGet(array(
'contentHash' => md5($content)
));
$cg->sendHeaders();
if ($cg->cacheIsValid) {
exit();
}
echo $content;
E.g. Static content with some static includes:
before content
$cg = new HTTP_ConditionalGet(array(
'lastUpdateTime' => max(
filemtime(__FILE__)
,filemtime('/path/to/header.inc')
,filemtime('/path/to/footer.inc')
)
));
$cg->sendHeaders();
if ($cg->cacheIsValid) {
exit();
}