开发者

How to cache Cake generated XML files?

This is specifically about CakePHP's caching system.

It seems to work fine caching view files, but not for xml files. This is the file I want to cache: /views/thing/xml/config.ctp

It is being called like this: http://website.com/thing/config.xml开发者_开发知识库

This is the class I have:

class ThingController extends AppController{ 
     public $helpers = array('Cache'); 
     public $cacheAction = array('config' => 36000); 
     function config(){ 
          // code here 
     } 
} 

I have tried, read the cookbook and googled for this but no result.

Anyone can tell me how do I cache an XML file that is generated by CakePHP?

:)


Just checked your code, and it's perfectly working on my end. Please check your Cache.disable or Cache.check keys in config/core.php. Also, double check if the webserver has write permission on app/tmp/cache. If the cache is working, there should be two files after the first time you have requested both /thing/config and /thing/config.xml: thing_config.php and thing_config_xml.php.

I remember there was a flaw in the Caching mechanism in 1.2, which caused cached views not to be served with the same mimetype as intended. http://www.mail-archive.com/cake-php@googlegroups.com/msg59379.html

There's also a link to the cookbook source, which shows how they solved it there.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜