Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • CacheHelper In CakePHP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 101
    Comment on it

    Cakephp cache used to store cache of entire layout and views. It store cache in tmp/cache/views/ folder. for use cache helper we need to use the below code in our controller

    var $helpers = array('cache');
    

    and we can also give cache time for example

    $this->cacheAction=array('duration'=>60);
    

    in this code caches the action for 60 second

    and for a partcular action we can use action name

    public $cacheAction = array(
        'view' => 36000,
        'index'  => 48000
    );
    

    Some time we don't want cache some part of a view we want a div or a form cache free for doing this we can use 'nocache'

    <!--nocache-->
    <?php if ($this->Session->check('User.id')): ?>
        Welcome, <?php echo h($this->Session->read('User.username')); ?>.
    <?php else: ?>
        <?php echo $this->Html->link('Signin', 'users/login'); ?>
    <?php endif; ?>
    <!--/nocache-->
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: