1

I wrote function to cache every page in my website and I put this function in Bootstrap file.

Cache files are created on every request, even for the same page.

Did I miss something?

It is also not working even if I remove regexps array from configuration.

Zend 1.12.3

protected function _initCache() {
    $cachePath = APPLICATION_PATH
        . DIRECTORY_SEPARATOR
        . '..'
        . DIRECTORY_SEPARATOR
        . '_cache';

    $fO = array(
        'lifetime' => 7200,
        'automatic_serialization' => true,
        'regexps' => array(
            '^/admin/' => array(
                'cache' => false
            ),
            '^/account/' => array(
                'cache' => false
            ),
            '^/cart/' => array(
                'cache' => false
            ),
        ),
        '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,
        ),
    );

    $bO = array(
        'cache_dir' => $cachePath
    );

    $cache = Zend_Cache::factory('Page', 'File', $fO, $bO);
    $cache->start();
}
sanneo
  • 365
  • 4
  • 15

1 Answers1

0

From zend docs:

Note: When using Zend_Cache, pay attention to the important cache identifier (passed to save() and start()). It must be unique for every resource you cache, otherwise unrelated cache records may wipe each other or, even worse, be displayed in place of the other.

read more

TreeNode
  • 472
  • 1
  • 7
  • 10
  • I think it is not a problem here. Zend_Cache generate id's automatically for start(), why is Zend_Cache generate another id (and cache file) for the same content? – sanneo Dec 18 '13 at 22:47
  • If not specify the parameters for start() method, zend creates id from 'Get', 'Post', 'Session', 'Files' and 'Cookie'. Are you sure that all of those same every time? – TreeNode Dec 18 '13 at 23:07