Coutputcache Errors And Oddities

As in this post on the same topic (never answered) I’m seeing unexpected behavior when trying to cache a page fragment containing a widget. In my case I’m tracing whether the initial expression:


if($this->beginCache('test', array('duration'=>60)))

ever evalutes to false (indicating successful retrieval from the cache), and it does not. It’s always true.

On the first iteration, the app log shows an entry like this:


[system.caching.CApcCache] Saving "Yii.COutputCache.test..lease/index...." to cache

That looks fine. (The string “lease/index” is the action portion of the URL.) It’s what I would expect to see. But on subsequent iterations the entry looks like this:


[system.caching.CApcCache] Saving "Yii.COutputCache.test..site/error...." to cache

How can I determine what’s going wrong? Thanks!

After more investigation I see that the problem is not just when there’s a widget. I can’t get caching to work right even in the simplest possible example. I reduced it to this:


<?php

Yii::log('test2 cache about to test');

if($this->beginCache('test2', array('duration'=>60))) {

Yii::log('test2 cache tests true');

?>

<div>The time is now.</div>

<?php

$this->endCache();

}

?>



In my app log, every time the ‘test2 cache about to test’ message is logged, the ‘test2 cache tests true’ message is also logged. Every time I refresh the page, even after just a couple of seconds.

On the first iteration, it logs what looks like a valid “Saving” message like the one in my OP. On every subsequent iteration I see that string containing ‘site/error’ instead of the proper URL.

This happens whether I’m using CMemCache or CApcCache. The behavior is the same.

When I run phpinfo() it shows both memcache and apc are installed. Yii doesn’t complain when I configure either one in my main config. What is going wrong?

No one has any guidance about where to look when ‘site/error’ shows up in the COutputCache log message?

There’s no evidence in the app log that the site/error URL is actually being requested. Am I the only one who’s seen this happen?

Thanks for any help!

Steve

Here’s additional info. When I configure caching to use CFileCache the behavior changes. At least the beginCache expression doesn’t always evaluate true, and therefore the cache component is sometimes serving content from the cache. But there’s still strangeness. I’m still seeing the “site/error” URL fragment when the actual URL requested is not that.

So I have two ongoing questions:

  1. Where can I look to find out why the "site/error" URL shows up in the cache instead of the actual URL?

  2. What could be wrong with my APC configuration to make the CApcCache component behave differently from CFileCache? (I’m attaching the APC portion of my phpinfo() in case that helps.)

3881

apcconfig.png