Forums / Developer / Caching causing problem for XML feed

Caching causing problem for XML feed

Author Message

Michael Hall

Monday 28 January 2008 8:34:29 pm

We have a page on our municipal council website which displays a 4 day weather forecast using an XML feed. The feed is working, but the page on our production site often displays data up to four days old, presumably because of caching. The same page on our dev site, which is not cached, always displays correct data.

The data is displayed using <custom name> tags in a "page" that is actually the description field of a published folder.

To force an update on the production site, I have to manually clear the Content View Cache. It will occasionally update itself, but without any discernible pattern.

As an eZ publish newbie, I don't know where to start trying to fix this. I've tried adding a {cache-block expiry=3600}{/cache-block} around the design template that publishes the forecast data (it is part of a custom extension), but it has no effect.

Do cache blocks work at this level?

Should I set up a cron job to force a daily clearance of the Content View Cache?

Is it normal for a site to go 3 or 4 days without the Content View Cache being renewed?
Should this cache should be renewed every two hours by default?

Any other suggestions? We only need this particular page/cache to be renewed once or twice a day.

I've read the documentation on cache-blocks but haven't found it particularly useful so far.

Łukasz Serwatka

Tuesday 29 January 2008 5:26:10 am

Hi Michael,

Could you write more how did you setup that XML feed? Was it via admin interface Setup->RSS or via layout module with enable XML header? Looks like view cache is not configured properly.

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Michael Hall

Tuesday 29 January 2008 3:15:10 pm

This was set up as an extension. A custom class fetches the data which is displayed using a custom template. I used the example on the eZ website for fetching currency data as a model.

Definitely not set up using RSS. I don't recall coding anything specific about XML headers.

Łukasz Serwatka

Wednesday 30 January 2008 12:23:12 am

I assume that you have build some fetch functions and you want to refresh content when source changed.

You can either disable view cache for that template:

{set-block scope=global variable=cache_ttl}0{/set-block}

http://ez.no/ezpublish/documentation/incoming/how_to_set_cache_expire_time_or_disable_cache_in_template

Or introduce a TTL variable in your PHP that will check last update and current time, then perform view cache clearing.

// Clear for node with ID 123
$nodeID = 123;
eZContentCache::cleanup( array( $nodeID ) );

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Gaetano Giunta

Wednesday 30 January 2008 12:58:59 am

As a side note: you should set up a correct pagelayout template and definitely content-type headers if you plan to produce xml via templating.

It is in fact quite easy to do, via the layout module. Just add this in an override file for layout.ini:

[xml]
PageLayout=xml_pagelayout.tpl
ContentType=text/xml

Then
- set up xml_pagelayout.tpl to contain the xml prolog
- use urls of the form ez/layout/set/xml/path/to/content to access your data in xml display mode

I would recommend creating a new view, eg: xml for displaying data as xml. This way you can still make use of node_view_gui and attribute_view_gui inside your templates. TEmplates to be done: /node/view/xml.tpl and content/datataype/view/xml/datatypexx.tpl

Principal Consultant International Business
Member of the Community Project Board

eZ debug

Timing: Jan 19 2025 04:36:07
Script start
Timing: Jan 19 2025 04:36:07
Module start 'content'
Timing: Jan 19 2025 04:36:08
Module end 'content'
Timing: Jan 19 2025 04:36:08
Script end

Main resources:

Total runtime0.9161 sec
Peak memory usage4,096.0000 KB
Database Queries202

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0061 588.9766180.8281
Module start 'content' 0.00620.7594 769.8047613.5859
Module end 'content' 0.76560.1505 1,383.3906337.3672
Script end 0.9160  1,720.7578 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00400.4366210.0002
Check MTime0.00150.1589210.0001
Mysql Total
Database connection0.00070.072010.0007
Mysqli_queries0.824590.00412020.0041
Looping result0.00220.23582000.0000
Template Total0.888096.920.4440
Template load0.00210.227320.0010
Template processing0.885996.702120.4429
Template load and register function0.00030.028010.0003
states
state_id_array0.00090.099910.0009
state_identifier_array0.00090.092920.0004
Override
Cache load0.00180.1960390.0000
Sytem overhead
Fetch class attribute can translate value0.00150.160840.0004
Fetch class attribute name0.00100.111270.0001
XML
Image XML parsing0.00140.155440.0004
class_abstraction
Instantiating content class attribute0.00000.001680.0000
General
dbfile0.00270.2981350.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
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.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: 24
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs