I am using this code
public function filters()
{
return array(
array(
'COutputCache + index',
'duration'=>Yii::app()->user->isGuest ? 3600 : 0,
//'varyByParam'=>array(),
),
array(
'CHttpCacheFilter + index',
'lastModified'=>Yii::app()->user->isGuest?Yii::app()->db->createCommand("SELECT MAX(`f_modified`) FROM {{post}}")->queryScalar():date('Y-m-d H:i:s'),
),
);
}
As you can see I have given duration and last modified in both depending on whether user is guest. Now when I logout my page is still showing that user is logged in.