默认phpcms v9没有文件缓存,但是它依然存在于系统公共函数文件中,在global.func.php 里有俩函数。
参照黄页系统,修改下 phpcms\modules\content\index.php ,在 show方法里开头结尾加上上面的函数即可.
自然会在cache文件,是不是很简单呢?有问题可以留言!
附带2函数如下:站长教学网 eduyo.com
/**
* 读取缓存动态页面
*/
function cache_page_start() {
$relate_url = isset($_SERVER['REQUEST_URI']) ? safe_replace($_SERVER['REQUEST_URI']) : $php_self.(isset($_SERVER['QUERY_STRING']) ? '?'.safe_replace($_SERVER['QUERY_STRING']) : $path_info);
define('CACHE_PAGE_ID', md5($relate_url));
$contents = getcache(CACHE_PAGE_ID, 'page_tmp/'.substr(CACHE_PAGE_ID, 0, 2));
if($contents && intval(substr($contents, 15, 10)) > SYS_TIME) {
echo substr($contents, 29);
exit;
}
if (!defined('HTML')) define('HTML',true);
return true;
}
/**
* 写入缓存动态页面
*/
function cache_page($ttl = 360, $isjs = 0) {
if($ttl == 0 || !defined('CACHE_PAGE_ID')) return false;
$contents = ob_get_contents();
if($isjs) $contents = format_js($contents);
$contents = "<!--expiretime:".(SYS_TIME + $ttl)."-->\n".$contents;
setcache(CACHE_PAGE_ID, $contents, 'page_tmp/'.substr(CACHE_PAGE_ID, 0, 2));
}
?>
(责任编辑:ken)