返回首页
当前位置: 首 页 > PHP框架 > Zend Framework >

Zend_Cache_Frontend_Page问题的解决

时间:2009-01-16 11:28来源:zfchina.org 作者:percila 点击:
发现是由于前面设置了SESSION,而导致SESSION与COOKIE中全有内容。。。而没有设置相关参数所以出现不能自动生成缓冲,代码修改成如下,就OK了
  刚开始的时候是用一个教程改的代码,但是发现无论如何也生成不了静态化,原始代码如下

PHP代码:
<?php

error_reporting
(E_ALL|E_STRICT);

date_default_timezone_set ('Asia/Shanghai');

set_include_path(".".PATH_SEPARATOR."./library".PATH_SEPARATOR."./application/models/".PATH_SEPARATOR.get_include_path());

include 
"Zend/Loader.php";

//Zend_Loader::loadClass("Zend_Controller_Front");

Zend_Loader::registerAutoload();





$config = new Zend_Config_Ini('./application/config.ini','default');

Zend_Session::start();

$testSpace = new Zend_Session_Namespace('testSpace');

$testSpace->"aaaaaaaaaa";

$registry Zend_Registry::getInstance();

$registry->set('config',$config);



$db Zend_Db::factory($config->db);

Zend_Db_Table::setDefaultAdapter($db);



$smtpconfig $config->smtp->params->toArray();

$smtpconfig = array('auth' => 'login',

            
'username' => 'xxx@xxx.net',

            
'password' => 'xxxxxxxxxxxx');

//var_dump($smtpconfig);

//$tr = new Zend_Mail_Transport_Smtp('smtp.togglethink.com',$config->smtp->toArray());

$tr = new Zend_Mail_Transport_Smtp('smtp.togglethink.com',$smtpconfig);

Zend_Mail::setDefaultTransport($tr);

       
$frontOption = array(

            
'lifetime' => true,

             
'debug_header' => true

             
'regexps' => array(

                     
'^/$' => array('cache' => true),

                    
'^/index/' => array('cache' => true,'cache_with_post_variables' => true,'make_id_with_post_variables' => true)

             )
        );

        
$backendOptions = array('cache_dir' => '/cache/');

        
$cache Zend_Cache::factory('Page','File',$frontOption,$backendOptions);

        
$cache->start();

$frontController Zend_Controller_Front::getInstance();

$frontController->setControllerDirectory("./application/controllers");

Zend_Layout::startMvc(array('layoutPath'=>'./application/layouts'));

//$x = new Zend_Controller_Request_Abstract();

//$x->getActionName()

$frontController->throwExceptions(true);

$frontController->dispatch();

?>

后来实在是没有办法了。。。只能去看ZF的源代码。。。要是俺当时英语好点就不用去看了。。。。发现是由于前面设置了SESSION,而导致SESSION与COOKIE中全有内容。。。而没有设置相关参数所以出现不能自动生成缓冲,代码修改成如下,就OK了

PHP代码:
$frontOption = array(

            
'lifetime' => true,

             
'debug_header' => true

             
'regexps' => array(

                    
'^/index/' => array('cache' => true,

                                        
'cache_with_get_variables' => true,

                                        
'cache_with_post_variables' => true,

                                        
'cache_with_session_variables' => true,

                                        
'cache_with_files_variables' => true,

                                        
'cache_with_cookie_variables' => true,

                                        )
             )
        );


标签: Zend_Cache
顶一下
(3)
60%
踩一下
(2)
40%
------分隔线----------------------------
最新评论 查看所有评论
发表评论 查看所有评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 密码: 验证码:
发布者资料
掂量 查看详细资料 发送留言 加为好友 用户等级:高级会员 注册时间:2009-01-05 00:01 最后登录:2010-03-05 11:03
推荐内容