Fragment Caching

I’m trying to implement a “Clear Cache” feature that’ll only clear particular assets. To do so, I’m making use of “Yii::app()->cache->delete(‘cache-key’)”. It doesn’t seem to be working and I suspect I know why. Is this method able to delete cached fragments that were set with beginCache() in a view? If Yii::app()->cache->delete() is the wrong method to use, does anyone have any suggestions on how to delete a particular fragment cache?



The cache key generated by COutputCache could be very complex. Unless you know the generated key, you will not be able to delete it manually from the cache.

As a workaround, you may create a COutputCache object with exactly the same configuration you use previously and then set its duration to be 0.

Thanks Qiang. That makes sense. I’ll give that a shot.