Harris
Harris

Reputation: 1138

Cake PHP Cache helper, cacheAction

I have the following in my controller:

var $cacheAction = array(
            'view/' => 432000,
            'pricelist/'=>'100000',
            'latest/' => '100000');

That is to cache the views for 5 days. I also enabled cache in core.php and included the cache helper in my controller.

The cache files are created correctly in tmp/cache/views/ but they don't seem to last for 5 days. If I do a file listing all files have been created in the last 3-4 minutes.

What am I doing wrong? Do I need another syntax for cache action?

thanks

Upvotes: 1

Views: 1735

Answers (2)

Harris
Harris

Reputation: 1138

My models are:

events hasMany Images

Basket belongsTo events hasMany BasketImages

BasketImages belongsTo images belongsTo basket

So I have cached the page events/view/id. In this view I have:

<?php if (($c=count($basketImages))>0) echo $c; ?>

and then there are some photos and a button which makes an ajax call like: /baskets/add/imageID

In basket/add, if user doesn't have a basket it creates one, and it also creates a BasketImage record with the current imageID.

So my question is do my page fall in the category where:

It is important to remember that the Cake will clear a cached view if a model used in the cached view is modified. (cookbook)

Does adding a basket and basketImage make events/view cache expiry? Can I use:

<cake:nocache> <?php if (($c=count($basketImages))>0) echo $c;?><cake:nocache> 

Upvotes: 0

Jack B Nimble
Jack B Nimble

Reputation: 5087

Are your actions using Models which change requently? From the Cookbook

It is important to remember that the Cake will clear a cached view if a model used in the cached view is modified. For example, if a cached view uses data from the Post model, and there has been an INSERT, UPDATE, or DELETE query made to a Post, the cache for that view is cleared, and new content is generated on the next request.

Upvotes: 3

Related Questions