Is it possible to turn off per-page-cache if user is logged in?

Is that possible to turn off cache component if user is not guest and use it if the user guest? If so, where can I configure that?


You could try this in your base controller (protected/components/Controller.php):

public function init()


    if (!Yii::app()->user->isGuest)

        Yii::app()->setComponent('cache', 'CDummyCache');



Not sure if it works though. Could be too late in the app life cycle. If it doesn’t work, ask again, you have even more options.

Mike, I believe it is too late. Here is what I get:

Fatal error: Call to a member function getIsInitialized() on a non-object in /var/www/framework/base/CModule.php on line 379

Thanks for the help though

Any other ideas?

Somehow it seems to me there is no elegant sollution to this issue.

Ah, sorry, the second parameter must be an object not a class name. So better try this:

Yii::app()->setComponent('cache',new CDummyCache);