Is Ok To Use Coutputcache And Chttpcachefilter Together?
Posted 15 February 2013 - 03:05 PM
I have been investigating about using CHttpCacheFilter and COutputCache. Both offers a good way to cache the entire page, but I could not find any reference about using both methods together.
In this case, what is the best way to enable page cache for guest users only? I noticed that when the user is logged out, the page is still cached.
Posted 18 February 2013 - 03:52 AM
For CHttpCacheFilter, once it's cached in the user's browser, it is staying there until it expires. The user logging out will not change anything there.
For differentiation between guests and logged in users, you probably want to use a duration of -1 for logged in users.
'duration'=> Yii::app()->user->isGuest ? 86400 : -1,
Posted 18 February 2013 - 08:14 AM
As a general rule of thumb, it is actually bad to combine several caching methods as you end up with holding the cache content twice. But the nature of http caching evens that one out. The best scenario for the combination of these methods is content that is (1) hard to generate and (2) quite sizable.
I originally intended to write a wiki article concerning this and a few tips and tricks that go beyond CHttpCacheFilter's documentation. But oh well, my tight time budget recently ...