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

eZ debug

Timing: Jan 18 2025 10:31:04
Script start
Timing: Jan 18 2025 10:31:04
Module start 'content'
Timing: Jan 18 2025 10:31:04
Module end 'content'
Timing: Jan 18 2025 10:31:05
Script end

Main resources:

Total runtime0.9925 sec
Peak memory usage4,096.0000 KB
Database Queries211

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0068 587.7109180.8359
Module start 'content' 0.00680.8060 768.5469660.3281
Module end 'content' 0.81290.1796 1,428.8750345.0625
Script end 0.9924  1,773.9375 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00470.4720210.0002
Check MTime0.00170.1695210.0001
Mysql Total
Database connection0.00100.100810.0010
Mysqli_queries0.902090.88132110.0043
Looping result0.00280.28582090.0000
Template Total0.960596.820.4802
Template load0.00250.256320.0013
Template processing0.957996.513820.4790
Template load and register function0.00010.013510.0001
states
state_id_array0.00150.153110.0015
state_identifier_array0.00160.158720.0008
Override
Cache load0.00230.2295500.0000
Sytem overhead
Fetch class attribute can translate value0.00150.155240.0004
Fetch class attribute name0.00120.1167100.0001
XML
Image XML parsing0.00150.156040.0004
class_abstraction
Instantiating content class attribute0.00000.0029130.0000
General
dbfile0.00230.2333360.0001
String conversion0.00000.000730.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
8content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
13content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
5content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
6content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 36
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs