Akelos Framework v1 forum archive. This forum is no longer maintained. To report bugs please visit https://github.com/akelos/akelos/issues
    •  
      CommentAuthorfrancois
     
    Hi everybody,

    I'm developing a website using Akelos and I need to use the caching system ( more than 20 simultaneous conexions ).

    When I use the $caches_action configuration,I have good performance results but can't determine if an user is connected or not (May be, someone have a solution using js and cookie).

    So, I start using the fragment caching in my tpl files. The performance are not so good and I have the following problem. When I click the first time to my page nothing appears. It's only the second time when the cached page has been generated that I can see the result.

    my source code in the tpl file

    <?php if (!$cache_helper->begin('promotionFragment')) { ?>
    <?php $items = $Item->findItemsByCategory(10); ?>
    <%= render :partial => 'promotion_items', :locals => {'items' => items} %>
    <?php $cache_helper->end('promotionFragment');}?>

    Has someone seen the same problem ?

    Thanks

    An Akelos Fan
    •  
      CommentAuthorfrancois
     
    Hi everybody,

    I think I have resolved my problem. I still use the action caching (faster option) and I implemented a beforeFilter in my controller which perform a renderAction method if the user is connected.
    So I can display a faster cached page if the user is not connected and a slower (action performed and template rendered) if the user is connected. I have used the code below in my controller.

    Class MyController extends MyOwnControlller{

    var $caches_action = array('show');

    function __construct(){
    parent::__construct();
    $this->beforeFilter(array('_checkUserConnected'=>array('only'=>array('show'))));
    }

    /**
    * Perform entire action if user is connected
    *
    */
    function _checkUserConnected(){
    if($this->isUserConnected()){
    $this->renderAction('show');
    }
    }
    }

    Thx
    • CommentAuthorarnoschn
     
    Hi Francois,

    to use fragment caching, refer to the inline documentation:

    * <b>Hello {name}</b>
    * <?php if (!$cache_helper->begin()) { ?>
    * All the topics in the system:
    * <?= $controller->renderPartial("topic", $Topic->findAll()); ?>
    * <?= $cache_helper->end();} ?>

    In your case:

    <?php if (!$cache_helper->begin('promotionFragment')) { ?>
    <?php $items = $Item->findItemsByCategory(10); ?>
    <%= render :partial => 'promotion_items', :locals => {'items' => items} %>
    <?php echo $cache_helper->end('promotionFragment');}?>

    - or -


    <?php if (!$cache_helper->begin('promotionFragment')) { ?>
    <?php $items = $Item->findItemsByCategory(10); ?>
    <%= render :partial => 'promotion_items', :locals => {'items' => items} %>
    <?= $cache_helper->end('promotionFragment');}?>

    Does that help?

    Arno
    •  
      CommentAuthorfrancois
     
    Thanks Arno,

    It's fixed now. I just forgot to put "echo" before the call of $cache_helper->end() method.

    Now, I will be able to process faster pages for the connected users using the fragment caching method.

    Regards

    Francois