Re: Using caching and threading to load a page quickly

2014-10-10 Thread Dave Watts

 Another approach would have the feed fetching functionality in a
 separate template which is run as a scheduled task every 2 minutes. That
 task can shove the parsed (and potentially formatted) feed into the
 application scope. (With a lock.) And then your main page can output
 that variable (with a lock). Then your home page would load as fast as
 it would as if the feed were local.

Based on all the information exchanged so far, this is the approach
I'd recommend. Just fetch it periodically and store it locally. Don't
wait for a user to request it first (as you're doing in another post).

Dave Watts, CTO, Fig Leaf Software
1-202-527-9569
http://www.figleaf.com/
http://training.figleaf.com/

Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on
GSA Schedule, and provides the highest caliber vendor-authorized
instruction at our training centers, online, or onsite.

~|
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:359448
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Using caching and threading to load a page quickly

2014-10-03 Thread Chris h

Thanks Jonah,

I am sorry for the late reply.

The WordPress's RSS feed is stable but due to excessive resource usage, the 
newswebsite has been suspended a few times after which we had to call the 
Hosting company to restore it. 

To have the rest of the page load and then the feed display later, 
you'll have to use AJAX to pull in a separate CF page clientside. (You'd 
still use caching in the feed.cfm so it'd only be slow occasionally.)

Would the following code http://collabedit.com/tmjwj/history function as 
expected in an environment with less users than actual production?

If the newswebsite is suspended because it is using too many resources on 
shared hosting, the thread reading the feed will timeout in 30 seconds, so 
there will be no results. Will News feed not available be shown?

Or, since the variable #feedResult.entriesNews# had a value from the last 
successful read, those results will be displayed?



Another approach would have the feed fetching functionality in a 
separate template which is run as a scheduled task every 2 minutes. That 
task can shove the parsed (and potentially formatted) feed into the 
application scope. (With a lock.) And then your main page can output 
that variable (with a lock). Then your home page would load as fast as 
it would as if the feed were local.


So, as you suggest, I need to get the feed, write to the machine running CF 
server which will be used if the RSS feed is unavailable, in case the 
newswebsite is suspended again.

I will make the feed loading a scheduled task and have to call it in the 
Application.cfm(I know most people have already moved to Application.cfc) and 
if no response is used, use the previous feed obtained from the past successful 
fetch.


I appreciate your assistance and time.


~|
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:359404
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Using caching and threading to load a page quickly

2014-09-28 Thread Chris h

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


Re: Using caching and threading to load a page quickly

2014-09-28 Thread .jonah

To have the rest of the page load and then the feed display later, 
you'll have to use AJAX to pull in a separate CF page clientside. (You'd 
still use caching in the feed.cfm so it'd only be slow occasionally.)

Another approach would have the feed fetching functionality in a 
separate template which is run as a scheduled task every 2 minutes. That 
task can shove the parsed (and potentially formatted) feed into the 
application scope. (With a lock.) And then your main page can output 
that variable (with a lock). Then your home page would load as fast as 
it would as if the feed were local.

On 9/28/14, 10:23 PM, Chris h wrote:
 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:359369
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm