Zend_Cache кэширует весь сайт вместо контроллера

Я хотел кешировать контроллер ajax

<?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();
    }
}

Но кеширование всего сайта, включая админку.


person Stanislav    schedule 08.02.2012    source источник


Ответы (1)


Используйте 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();
    }
}
person Hari K T    schedule 09.02.2012