2012-02-08 76 views
2

我想缓存控制器阿贾克斯Zend_Cache是​​缓存整个网站,而不是一个控制器

<?php 
class Default_Bootstrap extends Zend_Application_Module_Bootstrap 
{ 
    public function _initCache() 
    { 
     $frontendOptions = array(
      'lifetime' => 10800, 
      'automatic_serialization' => true, 
      'debug_header' => false, 
      'regexps' => array('^/ajax/' => array('cache' => true), 
           '^/admin/' => array('cache' => false)), 
      'default_options' => array(
      'cache_with_cookie_variables' => true, 
      'make_id_with_cookie_variables' => false)); 

     $backendOptions = array('cache_dir' => APPLICATION_PATH.'/data/cache'); 
     $cache = Zend_Cache::factory('Page','File',$frontendOptions,$backendOptions); 

     $cache->start(); 
    } 
} 

但缓存整个网站,包括管理模块。

回答

3

使用debug_header为true并检查下面的代码。由于我们首先设置为不缓存所有页面,并且只缓存以ajax开头的页面,我希望所有的ajax页面都以名称ajax开头,否则会相应地更改正则表达式。

class Default_Bootstrap extends Zend_Application_Module_Bootstrap 
{ 
    public function _initCache() 
    { 
     $frontendOptions = array(
      'lifetime' => 10800, 
      'automatic_serialization' => true, 
      'debug_header' => true,     
      'regexps' => array(
       '$' => array('cache' => false), 
       '/ajax' => array('cache' => true), 
      ), 
      'default_options' => array(
       'cache_with_cookie_variables' => true, 
       'make_id_with_cookie_variables' => false 
      ) 
     ); 

     $backendOptions = array('cache_dir' => APPLICATION_PATH.'/data/cache'); 
     $cache = Zend_Cache::factory('Page','File',$frontendOptions,$backendOptions); 

     $cache->start(); 
    } 
} 
相关问题