Caching action and main separately

Hey guys,

I've been playing with the view cache based on albumorama and default devtools scaffolding. One thing I've notices, is that the view cache caches the entire 'view' - action and main layouts. Is it possible to separate those, so only the /views/media/index.volt would get cached?

function indexAction() {      
        $key = 'media-index-all-latest';
        $exists = $this->view->getCache()->exists($key);                
        if( !$exists) {            
            $this->view->setVar('time', time());       
        }   
        $this->view->cache(
            array(  "lifetime" => 86400, "key"  => $key, )
        );                                       
    }

Thanks



81.8k

You can set the cache level as an option:

$this->view->cache(array("lifetime" => 86400, "key"  => $key, "level" => Phalcon\Mvc\View::LEVEL_ACTION_VIEW));


8.9k

I've tried that, and it still saves the entire page to the cache file. Could there be something else I may have accidentally changed?



81.8k

Try deleting your cache to force a cache regeneration



8.9k

Tried it. Tested with File backend and my own Wincache implementation and the same problem occurs.