Are you on Windows? My guess then would be: The filesystem itself is case independent, so if you use pure PHP everything wents fine. But APC is more sensible with upper lower cases of cached class files.
Just make sure your filenames always matches exactly and you should never have a problem on Windows AND Linux.
I mean that when include files in Case Sensitive OS/server, this is a problem, but when just call CHtml twice (second one with lower case like “Chtml”) it’s working and in my situation this was unexpected issue, because cache section actually hide part of my PHP code (including CHtml method).
However, the problem is fixed and the cache is working now.
Since the name of this topic is pretty general, I would like to ask one more question about fragment caching
In my application I retrieve some information from other site every 3 hours, insert it into database and make Yii::app()->cache->flush() to update a block on a site containing this information. Since it is the only block being cached, I can flush all cache info. But what if I have many cached blocks and I want to flush only one block’s cache? I tried:
but both lines don’t delete fragment cache file. I did a quick look at how file name is generated and it looks more complex than previous two lines.
After save both files, open home page and see the timestamp in sidebar, now go to "Comments" link on first blog post - timestamp is different!
Now you can click on index and “Comments” pages to see that we have different cache fragments… (timestamp is not changed until 600 secs, but in both pages timestamp is different)… which is the issue in my case.
Interesting . Would not have that expected that either.
beginCache() uses the COutputCache widget internally. It has some varyBy* properties. They define the condition, when another fragment should get cached even for the same id. And here you see that varyByRoute defaults to true. The problem should be gone if you use: