Good day,
I have run into some problem in the Zend_Cache_Frontend_Page. I want to use Zend_Cache_Frontend_Page to caching some of pages. But it does not work.
protected function _initBookPageCaching()
{
Zend_Controller_Front::getInstance()->setParam('disableOutputBuffering',true);
// cache book pages
$frontendOptionsPages = array(
'lifetime' => 2592000,
'debug_header' => true, // for debugging
'regexps' => array(
// cache the whole IndexController
'^/$' => array('cache' => true),
'^/download-free-ebook/.*' => array('cache' => true)
)
);
$backendOptionsPages = array(
'cache_dir' => APPLICATION_PATH.'/../cache'
);
$cacheBookPages = Zend_Cache::factory(
'Page',
'File',
$frontendOptionsPages,
$backendOptionsPages);
$cacheBookPages->start();
}
i set above method into Bootstrap.php file.
Please help me solve this problem.
Thanks for advance.
I never actually use Zend_Controller_Front::getInstance() in my bootstrap, rather I use:
followed by:
with which you could try:
Also, I’m not sure what the acceptable regex’s are for controllers and what not. Maybe try changing
'^/download-free-ebook/.*'to'^/download-free-ebook/'. And see if just the index action for that controller at least caches.EDIT:
I found the issue. $cache->start(); is returning false so I did some debugging. You’re not passing a cache id (e.g.
$cacheBookPages->start('some_cache_id');) so Zend_Cache_Frontend_Page attempts to make one for you on line 261. like so:So after following the rabbit trail, I realized that it was trying to build a cache id based off the following arrays: $_GET, $_POST, $_SESSION, $_COOKIE and $_FILES. Since none of those are set it is unable to create a cache id! And since it can’t create a cache id, it can’t create the cache file.
Solution: