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.
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();} ?>