Full page cache with APC possible? (CakePHP)

老子叫甜甜 提交于 2019-12-11 10:33:47

问题


I have my website cached using full page caching. So for every page an html file is created.

As I am using CakePHP, I can define that APC caching would be used instead of file caching. However, if done that, html files are still being created (APC is installed correctly).

So question: is there any logic in using APC with full page caching? Does it give any benefits? Is it possible to put cached html file to RAM somehow and read it from there when needed?

P.S. I am not talking about APC opcode caching functionality. Just data caching.


回答1:


Yes, you can cache whole your HTML view file in cache with APC cache engine in CakePHP. Cake's CacheHelper will do that job for you. Suppose you have a PostsController and you want to cache all your view files related this controller. In this case first of all you have to define the following code in your controller.

   class PostsController extends AppController {
       public $helpers = array('Cache');
   }

And in your bootstrap.php file you have to add the CacheDispatcher.

   Configure::write('Dispatcher.filters', array(
        'CacheDispatcher'
       )
   );

And now again in your PostsController you have to tell about the cache files.

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

This will cache the view action 10 hours, and the index action 13 hours.

I think from now on you can serve your whole HTML cached view file to your visitors without hitting PHP or Cake in your server. Thanks.



来源:https://stackoverflow.com/questions/16394168/full-page-cache-with-apc-possible-cakephp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!