本文整理汇总了PHP中http::cache_max_age方法的典型用法代码示例。如果您正苦于以下问题:PHP http::cache_max_age方法的具体用法?PHP http::cache_max_age怎么用?PHP http::cache_max_age使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类http
的用法示例。
在下文中一共展示了http::cache_max_age方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
http::head(404, 'Not Found');
exit;
}
$allow_types = array('png', 'jpg', 'jpeg', 'gif', 'css', 'js', 'swf');
$pf = path::clean($_GET['pf']);
$paths = array_reverse(explode(PATH_SEPARATOR, DC_PLUGINS_ROOT));
# Adding admin/res folder here to load some stuff
$paths[] = dirname(__FILE__) . '/swf';
foreach ($paths as $m) {
$PF = path::real($m . '/' . $pf);
if ($PF !== false) {
break;
}
}
unset($paths);
if ($PF === false || !is_file($PF) || !is_readable($PF)) {
header('Content-Type: text/plain');
http::head(404, 'Not Found');
exit;
}
if (!in_array(files::getExtension($PF), $allow_types)) {
header('Content-Type: text/plain');
http::head(404, 'Not Found');
exit;
}
http::$cache_max_age = 7200;
http::cache(array_merge(array($PF), get_included_files()));
header('Content-Type: ' . files::getMimeType($PF));
header('Content-Length: ' . filesize($PF));
readfile($PF);
exit;
示例2: dirname
$pf = path::clean($_GET['pf']);
$paths = array_reverse(explode(PATH_SEPARATOR, DC_PLUGINS_ROOT));
# Adding some folders here to load some stuff
$paths[] = dirname(__FILE__) . '/swf';
$paths[] = dirname(__FILE__) . '/js';
$paths[] = dirname(__FILE__) . '/css';
foreach ($paths as $m) {
$PF = path::real($m . '/' . $pf);
if ($PF !== false) {
break;
}
}
unset($paths);
if ($PF === false || !is_file($PF) || !is_readable($PF)) {
header('Content-Type: text/plain');
http::head(404, 'Not Found');
exit;
}
if (!in_array(files::getExtension($PF), $allow_types)) {
header('Content-Type: text/plain');
http::head(404, 'Not Found');
exit;
}
http::$cache_max_age = 7 * 24 * 60 * 60;
// One week cache for plugin's files served by ?pf=… is better than old 2 hours
http::cache(array_merge(array($PF), get_included_files()));
header('Content-Type: ' . files::getMimeType($PF));
// Content-length is not mandatory and must be the exact size of content transfered AFTER possible compression (gzip, deflate, …)
//header('Content-Length: '.filesize($PF));
readfile($PF);
exit;