dckurushin
(Diavolonok)
1
Hello, I want to cache whole index page, but only for guests…
What is the best way to do it?
I have for example
public function filters()
{
return array(
array(
'COutputCache + index',
'duration'=>100,
),
);
}
There is a
'varyBySession'=> true,
But it not doing what I need… also I dont want to cache it at all for users…
So what is the way to go?
I can do it very ugly with
public function filters()
{
return array(
array(
'COutputCache +' . (Yii::app()->user->isGuest ? 'index':''),
'duration'=>60,
/*'varyBySession'=> true,*/
),
);
}
Some one have a better idea ?
dckurushin
(Diavolonok)
2
Also I want to cache page content
I have
'page'=>array(
'class'=>'CViewAction',
),
And the routes look like page/rules.html page/contact.html etc.
I want to cache it… how to do it?
If I add COutputCache + page/rules,page/contact
It will serve me the same page every time (the first it cached)
dckurushin
(Diavolonok)
4
Da:Sourcerer
Dont sure if that is what I want…
varyByExpression
I don’t want it to cache at all for users (because I have user menu etc.)
Also I’m not sure I can combine all the login in one array of COutputCache…
For now this is what I got
public function filters()
{
return array(
array(//http://www.yiiframework.com/doc/api/1.1/COutputCache
'COutputCache + , ' . (Yii::app()->user->isGuest ? 'index':''),
'duration'=>60,
),
array(//http://www.yiiframework.com/doc/api/1.1/COutputCache
'COutputCache + page',
'duration'=>60,
'varyByParam' => array('view'),
),
);
}