php - CakePHP caching elements with duration -
regarding cookbook can cache elements this:
echo $this->element('helpbox', array(), array('cache' => true));
caching configuration this:
echo $this->element('helpbox', array(), array('cache' => array('config' => 'view_long') );
how can cache elements without predefined configuration ? how can cache duration elements? tried this, didn't work:
echo $this->element('helpbox', array(), array('cache' => array('time' => '+30 minutes')));
you need configure cache in app/config/bootstrap.php
:
cache::config('hour', array( 'engine' => 'file', 'duration' => '+1 hours', 'path' => cache, 'prefix' => 'cake_short_' )); cache::config('week', array( 'engine' => 'file', 'duration' => '+1 week', 'probability' => 100, 'path' => cache . 'long' . ds, ));
after can cache element using defined configuration:
echo $this->element('helpbox', array(), array('cache' => array('config' => 'week')));
Comments
Post a Comment