本文整理匯總了PHP中Smarty_Internal_Template::isCached方法的典型用法代碼示例。如果您正苦於以下問題:PHP Smarty_Internal_Template::isCached方法的具體用法?PHP Smarty_Internal_Template::isCached怎麽用?PHP Smarty_Internal_Template::isCached使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Smarty_Internal_Template
的用法示例。
在下文中一共展示了Smarty_Internal_Template::isCached方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: cacheModifiedCheck
/**
* check client side cache
*
* @param \Smarty_Template_Cached $cached
* @param \Smarty_Internal_Template $_template
* @param string $content
*/
public function cacheModifiedCheck(Smarty_Template_Cached $cached, Smarty_Internal_Template $_template, $content)
{
$_isCached = $_template->isCached() && !$_template->compiled->has_nocache_code;
$_last_modified_date = @substr($_SERVER['HTTP_IF_MODIFIED_SINCE'], 0, strpos($_SERVER['HTTP_IF_MODIFIED_SINCE'], 'GMT') + 3);
if ($_isCached && $cached->timestamp <= strtotime($_last_modified_date)) {
switch (PHP_SAPI) {
case 'cgi':
// php-cgi < 5.3
// php-cgi < 5.3
case 'cgi-fcgi':
// php-cgi >= 5.3
// php-cgi >= 5.3
case 'fpm-fcgi':
// php-fpm >= 5.3.3
header('Status: 304 Not Modified');
break;
case 'cli':
if (!empty($_SERVER['SMARTY_PHPUNIT_DISABLE_HEADERS'])) {
$_SERVER['SMARTY_PHPUNIT_HEADERS'][] = '304 Not Modified';
}
break;
default:
if (!empty($_SERVER['SMARTY_PHPUNIT_DISABLE_HEADERS'])) {
$_SERVER['SMARTY_PHPUNIT_HEADERS'][] = '304 Not Modified';
} else {
header($_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified');
}
break;
}
} else {
switch (PHP_SAPI) {
case 'cli':
if (!empty($_SERVER['SMARTY_PHPUNIT_DISABLE_HEADERS'])) {
$_SERVER['SMARTY_PHPUNIT_HEADERS'][] = 'Last-Modified: ' . gmdate('D, d M Y H:i:s', $cached->timestamp) . ' GMT';
}
break;
default:
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $cached->timestamp) . ' GMT');
break;
}
echo $content;
}
}