1

I'm using this function in Bootstrap.php to cache my controllers , and i need to cache some controllers only I don't need to cache index controller and article controller as an example and i need to cache question controller but it does not working . this function is cached all my controllers

protected function _initCache()
{
    mb_internal_encoding("UTF-8");
    $dir = "/var/www/data/cache/all";

   $frontendOptions = array(
        'lifetime' => 3600,
        'content_type_memorization' => true,
        'default_options'           => array(
        'cache' => true,
        'cache_with_get_variables' => true,
        'cache_with_post_variables' => true,
        'cache_with_session_variables' => true,
        'cache_with_cookie_variables' => true,
        ),
    'regexps' => array(

             '^/$' => array('cache' => false),
            "^/question/" => array('cache' => true),
            "^/article/" => array('cache' => false),
             )
    );
    $backendOptions = array(
            'cache_dir' =>$dir
    );

    // getting a Zend_Cache_Frontend_Page object
    $cache = Zend_Cache::factory('Page',
                         'File',
                         $frontendOptions,
                         $backendOptions);

    $cache->start();
}

so what i can do I tried all soluations please help me. Thanks

Osama Jetawe
  • 2,697
  • 6
  • 24
  • 40

1 Answers1

0

Create a controller plugin with that code, and detect the request. Something like...

if($request->getControllerName() == 'index' || ... == 'article') {
return;
}
mb_internal_encoding("UTF-8");
...
James Elliott
  • 1,012
  • 9
  • 20
  • Thank you I did somethings like your solution , but in my function in Bootstrap using $request = $_SERVER['REQUEST_URI']; if ($request == 'artice') { /* my function to do Cache*/ } Thanks a lot – Osama Jetawe Jun 20 '13 at 14:07