Our software uses the following method for element caching in a cakePHP app:
Sample code:
<?php echo $this->element('cities-index', array('Cache' => array('time' => "12 hours")));?>
Based on the documentation, this should work just fine.
I've isolated this statement as a major cause of our web page loading slowly (this operation is costing us 0.2s per page execution), and I've come to the discovery that caching is doing absolutely nothing.
Caching is enabled in core.php and set to file, and the app/tmp folder has the right permissions. We've painstakingly gone through the cakePHP docs and are stumped.
开发者_运维知识库We'd appreciate any assistance, thanks!
Lower case 'cache' '+12 hour' rather than '12 hours' Added a key
$this->element('cities-index', array('cache' => array('key'=>'cities-cache','time' => '+12 hour')));
Nik posted the correct answer first but in a comment to the original post. It may have gone unnoticed.
I don't know what is your cache configuration, but for me caching the elements doesn't mean that you caching the controller's and models calls (where I think is the real bottleneck). Try to cache the database calls and probably your app will become faster.
What is your debug level set to? Certain debug level (1 or 2 - I can't remember) will disable caching.
This may also vary between CakePHP 1.2.x and 1.3.x - so know what version would be helpful too.
精彩评论