Hi All,

I have a main index page which is in ColdFusion which gets a RSS feed from 
another website(Newswebsite which is a WordPress 3.9.2 website running on 
shared hosting). The Newswebsite is on shared hosting so takes about 7 seconds 
to load(a little slow, I know, but the decision to go with a shared hosting was 
done to save on costs by the purchasing people).

Now, people don't want the main index page to take 7 seconds to load. I 
estimate using caching of the RSS feed so that updates are retrieved from the 
feed only every 2 minutes and having a thread so that the main index page 
loads(in 2 seconds or less) without waiting for the RSS feed can alleviate the 
issue. The thread which fetches the data from RSS feed can display the feeds on 
the main index page after the data is retrieved.

1. If the idea is viable, would something like the below work?

-----------------------------------------------------------------------------------------------------------------------------

<cftry>
<cfset rssUrl = "http://www.testsite.com/?feed=rss2";>
   
    <!--- Caching the RSS feed from newssite so that it is checked every 2 
minutes only--->
    <cfcache action = "cache" timespan = "#createtimespan(0,0,2,0)#">   
   
    <!--- Start a thread and wait for it to read the RSS feed from newssite --->
    <cfthread action="run" name="thread1">
        <cffeed action="read" source="#rssUrl#" query="entriesNews" 
properties="info" timeout = "180">                      
     </cfthread>
           
     <cfthread action="join" name="thread1" timeout="7000" />
     
      <cfset feedResult=cfthread["thread1"]>
            
             <!--- Display feed information if it was obtained in 7 seconds 
--->                     
       <cfif isDefined("feedResult.entriesNews")>
               <ul>    
             <cfoutput query="entriesNews" startrow="1" maxrows="3">     
                 <cfset tempTextNews = #title#>  
                 <cfif len(tempTextNews) gt '75'>   
                 <li>
                 <a class="NewsEvents" href="#rssLink#" 
target="_blank">#Left(tempTextNews, 75)#...more</a>
                 </li>
                 <cfelse>
                 <li>
                 <a class="NewsEvents" href="#rssLink#" 
target="_blank">#title#...more</a>
                 </li>
                 </cfif>
             </cfoutput>
      </cfif>       
        
    </cfcache>     
     
        <cfcatch type="any">
            <!--                            <cfdump var="#entriesNews#"> --->
            <!--                            <cfdump var="#info#"> --->          
                 
            News Feed not available              
        </cfcatch>                 
        </ul>
</cftry>


-----------------------------------------------------------------------------------------------------------------------------

2. Are there other better ways to tackle the issue?

I want the other parts of the main index page which is in ColdFusion to load 
and not get delayed because getting data from the RSS feed of news website 
takes 7 seconds.

Any suggestions would be appreciated.

Thanks 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:359368
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to