tp3.2 的2個文件
app\common\behavior\ 文件夾
百度下載
tags.php
// 應用行爲擴展定義文件
return [
// 應用初始化
'app_init' => [],
// 應用開始
'app_begin' => [],
// 模塊初始化
'module_init' => ['app\\common\\behavior\\ReadHtmlCacheBehavior'],
// 操作開始執行
'action_begin' => [],
// 視圖內容過濾
'view_filter' => ['app\\common\\behavior\\WriteHtmlCacheBehavior'],
// 日誌寫入
'log_write' => [],
// 應用結束
'app_end' => [],
];
修改文件的namespace
添加配置到文件 app\config.php
// +----------------------------------------------------------------------
// | 靜態緩存
// +----------------------------------------------------------------------
'html_cache_on' => true, // 開啓靜態緩存
'html_cache_time' => 7200, // 全局靜態緩存有效期(秒)
'html_file_suffix' => '.shtml', // 設置靜態緩存文件後綴
'html_cache_compile_type' => 'file',//緩存存儲驅動
'html_cache_rules' => array(
// 定義靜態緩存規則
// // 定義格式1 數組方式
//'靜態地址' => array('靜態規則', '有效期', '附加規則'),
//1.任意控制器的任意操作都適用
'*' => array('{$_SERVER.REQUEST_URI|md5}'),
//2.任意控制器的md5操作
'md5' => array('{:module}/{:controller}/{:action}_{id|md5}'),
//3.Static控制器的所有操作
'Static:' => array('{:module}/{:controller}/{:action}', 50),//第一個參數是構造的字符串,後面是緩存50秒
//4.Hmtl控制器的md5操作
'Html:md5' => array('{:module}/{:controller}/{:action}'),
),