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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 31 2025 01:15:14
Script start
Timing: Jan 31 2025 01:15:14
Module start 'layout'
Timing: Jan 31 2025 01:15:14
Module start 'content'
Timing: Jan 31 2025 01:15:15
Module end 'content'
Timing: Jan 31 2025 01:15:15
Script end

Main resources:

Total runtime0.0220 sec
Peak memory usage4,096.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0054 588.1563151.2109
Module start 'layout' 0.00540.0029 739.3672220.6875
Module start 'content' 0.00830.0124 960.05471,001.9297
Module end 'content' 0.02070.0013 1,961.984437.9922
Script end 0.0220  1,999.9766 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002612.0053140.0002
Check MTime0.00104.5857140.0001
Mysql Total
Database connection0.00104.652910.0010
Mysqli_queries0.00167.305930.0005
Looping result0.00000.041210.0000
Template Total0.00094.210.0009
Template load0.00062.808010.0006
Template processing0.00031.345510.0003
Override
Cache load0.00042.004110.0004
General
dbfile0.00167.223680.0002
String conversion0.00000.013040.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs