Coutputcache & Header

Hello everyone,

I’im using COutputCache and I just wonder how can I refresh cache when user is logged and when user clicks “Logout”? I think there is a better way instead of saving and removing users in a table.

Thanks.

EDIT:

Also, I would like to know how can I update my blog post (example). There is a column "total_views", and If my page is cached, how can I do:


$blog=Blog::model()->findByPk($id);

$blog->total_views=$blog->total_views+1;

$blog->update();

It’s not possible, because blog post is cached.

Thanks again.

Consider using "Dynamic Content".

http://www.yiiframework.com/doc/guide/1.1/en/caching.dynamic

I would not use query caching for a single record. It doesn’t seem very effective to me, considering the overhead of dependency management.

But if I ever have to use it, I will probably create a separate table for total_views.

Thank you very much.

Well it’s better because of that I’ve one table with about 7 left joins, so it’s recommended. It’s not problem to create a seperate table but where to execute a query? Whole page is cached (COutputCache).

Where do execute:




$st = SeperateTable::model()->findByPk($id);

$st->total_views=$st->total_views+1;

$st->update();



? Thanks.

So, you may consider using “Dynamic Content”. :)

Lol, my mistake. But now the problem is that Yii returns:

<###dynamic-0###>

Thanks.