Hi Dan

Thanks for that - it seems to be working fine.  So this will now cache
the RSS feed to the application scope for 20 mins, so the CFHTTP tag
does not need to go out to the Internet within the 20 minute timeframe
as the data from the feed is cached?  



-----Original Message-----
From: Dan G. Switzer, II [mailto:[EMAIL PROTECTED] 
Sent: 24 December 2007 12:43
To: CF-Talk
Subject: RE: CFHTTP and Caching

Ian,

>This is the error I am getting below even though weather_xml has been
>defined in the application.cfm page
>
>i.e. <CFSET APPLICATION.weather_xml =XMLParse(cfhttp.FileContent)>
>
>ERROR IS
>----
>Element WEATHER_XML is undefined in APPLICATION.
>----
>
>My application.cfm page is
>
>----
><cfset Application.TimeStamp="#TimeFormat(now(), 'hh:mm:ss')#">
>
><CFIF (APPLICATION.TimeStamp EQ "") OR (DateDiff("n",
>APPLICATION.TimeStamp, TimeFormat(NOW(), "hh:mm:s")) GT 20)> <CFSET
>APPLICATION.TimeStamp = CreateTime(TimeFormat(NOW(), "hh"),
>TimeFormat(NOW(), "mm"), TimeFormat(NOW(), "s"))>
>
><cfhttp url="http://feeds.bbc.co.uk/weather/feeds/rss/5day/id/3314.xml";
>method="GET" resolveurl="No"></cfhttp>
><CFSET APPLICATION.weather_xml =XMLParse(cfhttp.FileContent)>
>
></CFIF>

The way that logic reads, the Application.TimeStamp will always be "less
than" 20 the first time the application is loaded--so your CFHTTP tag
will
never run.

Change the code to something like:

<cfif 
        not structKeyExists(Application, "TimeStamp") 
                or 
        (dateDiff("n", Application.TimeStamp, now()) gt 20)> 

        <cfset Application.TimeStamp = now() />

        <cfhttp
        
url="http://feeds.bbc.co.uk/weather/feeds/rss/5day/id/3314.xml";
                method="GET" resolveurl="No"></cfhttp>
        <cfset Application.weather_xml = xmlParse(cfhttp.FileContent) />

</cfif>

There's no need to convert your Application.TimeStamp variable to any
specific formatting--you can just set it to now().

-Dan




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:295476
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to