Forums / Setup & design / Caching expiring regularly

Caching expiring regularly

Author Message

Christian Johansen

Tuesday 11 September 2007 8:00:09 am

Hi,

I recently worked out a new site which extensively cross reference content. The right column frequently list out contents of sibling nodes children and so on. All in all I came to the conclusion that the view caching wouldn't be suitable for my needs here, so most of the full templates disables view caching in favor of cache blocks.

So most of the templates are divided into cache-blocks, some of them have keys=$node.url_alias, some have timeout in minutes (small blocks) and some have subtree expiry. The problem I'm facing is that all my caches seem to expire on a regular basis.

The cache blocks that expire on seconds seem to work fine. One page lags when they are recreated, then the rest of the pages that use the same cache block are fine.

So, why does my cache expire when I'm not publishing content? I read about the 2 hour default cache ttl under the cache-block docs, but the way I understand it this shouldn't come into effect when I'm using subtree expiry or keys? Do I have to set expiry=0 keys=$node.url_alias?

What about the few pages that are cached by the normal view caching? They too expire, even when I'm not publishing content. Does the view cache only live for 2 hours? How can I disable that feature?

André R.

Tuesday 11 September 2007 2:10:18 pm

Hi!

only subtree_expiry will 'will implicitly turn on the "ignore_content_expiry" and set the expiration time to zero.'
Other cache blocks will expire when content is published or time to live (ttl) is reached.
So use subtree_expiry wherever you can, and on the others consider "ignore_content_expiry and specify a cache time you are comfortable with.

On view cache, this is a bit different. They have a infinite ttl by default, but can be cleared when related, reverse related, linked, children or the page it self is published. This is controlled by viewcache.ini, where you can also control this pr class.

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Christian Johansen

Tuesday 11 September 2007 3:08:59 pm

Aha, so I guess I'll change most of the keys= to subtree_expiry instead, that makes sense. I've used the view cache extensively in the past and never had any trouble with it. Now, however, my frontpage, which uses view cache, will be completely regenerated if it has not been visited in an hour or two, even if nothing has happened.

Today I generated caches before leaving work. All pages loads fast. When I check this evening, everything must be regenerated. And I'm the only person with access to it. How can I debug this?

Marko Žmak

Wednesday 12 September 2007 2:05:47 am

Andre, as far as I know, the statement:

only subtree_expiry will 'will implicitly turn on the "ignore_content_expiry" and set the expiration time to zero.'

is not quite true, as you can see here:

http://issues.ez.no/IssueView.php?Id=8817

I don't know if the eZ cache mechanism has changed since then, but if it's not, then the documentation is wrong (which was noticed in the bug comment, but no one changed the docs).
As far as I know, you have to explicitly set ignore_content_expiry and expiry=0 when using subtree_expiry.

To avoid further confusion, could someone from the eZ crew check how really cache-blocks works with subtree_expiry, and correct the documentation if needed?

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

André R.

Wednesday 12 September 2007 3:37:52 am

I was quoting the doc, if it ain't so it's a bug, in ezp or the doc!

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Marko Žmak

Wednesday 12 September 2007 3:48:09 am

Yes, I think that it's a bug in docs, it was mentioned in the comment to the bug I posted, but noone corrected it.
It would be nice if someone from eZ crew could check this and correct the docs.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Christian Johansen

Thursday 13 September 2007 2:41:39 am

I have now added expiry=0 to all my cache-blocks with keys, and added expiry=0 and ignore_content_expiry on all cache-blocks that use subtree_expiry. Still, my site becomes completely stale after some time (1 or 2 hours). Even pages that use only normal view caching becoms stale after a period of time, even with no visits or edits or no nuthin'.

Any other ideas? I tried to raise the threshold too, to 150. I don't know exactly how this works. I use a cache block on some pages that expire every 10 minutes. If that cache-block will trigger the deletion of caches for 150 nodes or more all caches are cleared, correct? But, are those cache-blocks validated on pages that don't use them? That could maybe explain why my frontpage which is chemically clean of cache-blocks is stale (if the cache-blocks are validated anyway). But it doesn't make any sense to me. Besides, I don't have 150 nodes in my install.

Any other ideas as to what's going on here?

André R.

Thursday 13 September 2007 4:29:44 am

And you have cleared template cache after you did those changes?
One thing you could do is log when the cache blocks are regenerated.

the file: lib/eztemplate/classes/eztemplatecachefunction.php around
line 294 you will finde something like this:

                  "\$fd = fopen( $filedirText. '/'. \$uniqid, 'w' );\n" .
                  "fwrite( \$fd, \$cachedText );\n" .

Add something like this:

                  "eZDebug::writeError( \$globalExpiryTime . ' ' . \$filedirText . ' ' . \$keyString . ' ' . \$subtreeExpiry, 'ViewCache regenerated' );\n" .

Then you need to clear template cache and hope that it 1) works and 2) gives some menaingfull information.
This will be logged in var/log/error.log.

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom