0
votes

I am using CakePHP. I have an action in a controller that produces the static content pages of an app. I want to cache this entire action/view. The controller is Pages and the action is Main. I am not seeing the cached files for the view appear in the tmp/cache folder.

  • I have uncommented the Cache.check setting in core.php, so it reads:

    Configure::write('Cache.check', true);

  • I have added the cache helper to the pages controller:

    var $helpers = array('javascript','cache');

  • I have told the controller to cache the action called "main":

    var $cacheAction = array('main/'=>86400);

  • I have confirmed there are other cache files (the model cache) in the app/tmp/cache folder from today, so I know this isn't a permissions issue.

Here is the top of my pages controller:

var $name = 'Pages';
var $helpers = array('Javascript','Cache');
var $uses = array();
var $components = array('Authentication','Security');
var $cacheAction = array('main/'=>86400);

I am not sure what I am missing to enable the cache of a view in CachePHP. Am I missing something? Any ideas?

2
have you got any solution for this? m trying for the same - Er.KT

2 Answers

0
votes

Dumb checks, sorry, but just to make sure:

Capitalise the words 'javascript' and 'cache'

i.e. var $helpers = array('Javascript','Cache'); not as you have pasted.

Ensure you've added

var $cacheAction = array('main/'=>86400); and

var $helpers = array('Javascript','Cache');

at Class level in the appropriate controller.

It might be worth trying the helper declaration in the app_controller.

I don't know if you're on Windows or something more sensible. If you're on Linux or OSX or whatever, in a console window, change directory to app/tmp and chmod -R 777 . It's probably worthwhile recursively chown & chgrp to whatever the web user is, too.

Delete all the cache files - leave the directories there.

Try again.

0
votes