可以使用APC进行全页缓存吗? (CakePHP) [英] Full page cache with APC possible? (CakePHP)

查看:82
本文介绍了可以使用APC进行全页缓存吗? (CakePHP)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用全页缓存来缓存我的网站.因此,每个页面都会创建一个html文件.

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

当我使用CakePHP时,我可以定义将使用APC缓存而不是文件缓存.但是,如果这样做,仍会创建html文件(正确安装了APC).

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).

那么问题:将APC与全页缓存一起使用是否有逻辑?有什么好处吗?是否可以将缓存的html文件以某种方式放入RAM并在需要时从那里读取?

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.我不是在谈论APC操作码缓存功能.只是数据缓存.

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

推荐答案

是的,您可以使用CakePHP中的APC缓存引擎将整个HTML视图文件缓存在缓存中. Cake的 CacheHelper 将为您完成这项工作.假设您有一个 PostsController ,并且要缓存与此控制器相关的所有视图文件.在这种情况下,首先必须在控制器中定义以下代码.

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');
   }

在您的 bootstrap.php 文件中,您必须添加 CacheDispatcher .

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

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

现在再次在您的 PostsController 中,您需要讲述缓存文件.

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

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

这将缓存视图操作10小时,索引操作13小时.

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

我认为从现在开始,您可以将整个HTML缓存的视图文件提供给访问者,而无需在服务器中使用PHP或Cake.谢谢.

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.

这篇关于可以使用APC进行全页缓存吗? (CakePHP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆