Zend page caching similar to smarty?

I there a way to make zend_cache treat front end view similar to smarty? I would like to reduce load times and page caching seems the best way todo this.

Also it would need something similar to {nocache}.

Okay so I now have: Bootstrap.php

    protected function _initCache() {

    $this->bootstrap('locale');
    $locale = $this->getResource('locale');

    $front = array ( 'lifetime' => 1800,
    'automatic_serialization' => false,
    'caching' => true,
    'cache_id_prefix' => 'ec_',
    'debug_header' => true, 

    'default_options' 
        => array ('cache_with_get_variables' => true,
        'cache_with_post_variables' => false,
        'cache_with_session_variables' => false,
        'cache_with_cookie_variables' => false ),
    );

    $back = array('cache_dir' => '../data/Cache/'.$locale);

    $cache = Zend_Cache::factory('Page', 'File', $front, $back);
    $cache->start();
    Zend_Registry::set('cache', $cache);
    return $cache;
}

However, the only time my cache is hit is with code like:

$cache = Zend_Registry::get('cache');

            if (!$data = $cache->load('sidebar_'.$module.'_'.$controller)) {
                $data['Studio']     = Eurocreme_Studio::load_by_type(array('type' => 'sidebar', 'from' => 0, 'to' => COUNT_HIGH));
                $data['Movie']      = Eurocreme_Movie::load_by_type(array('type' => 'sidebar', 'from' => 0, 'to' => 5));
                $data['Gallery']    = Eurocreme_Gallery::load_by_type(array('type' => 'sidebar', 'from' => 0, 'to' => 5));
                $data['Category']   = Eurocreme_Category::load_tree(0);
                $cache->save($data, 'my_view_helper_sidebar_'.$module.'_'.$controller);
            }

I was hoping to capture the entire views.

Does anyone have any working examples of how to implement it fully? The docs don't really go in-depth.

2 Answers

  1. Edwin- Reply

    2019-11-15

    You may want to use Zend_Cache_Frontend_Output or Zend_Cache_Frontend_Page. From Zend Framework manual:

    Zend_Cache_Frontend_Output is an output-capturing frontend. It utilizes output buffering in PHP to capture everything between its start() and end() methods.

    Zend_Cache_Frontend_Page is like Zend_Cache_Frontend_Output but designed for a complete page.

Leave a Reply

Your email address will not be published. Required fields are marked *

You can use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>