Share » Forums » Developer » Caching causing problem for XML feed

Caching causing problem for XML feed

Caching causing problem for XML feed

Monday 28 January 2008 8:34:29 pm - 4 replies

Modified on Monday 28 January 2008 8:35:50 pm by Michael Hall

Author Message

Ł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

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu