1

This is a question i've been pondering about for a while :-) Clients are often asking if it's possible to create a real-time page update whenever they upload i.e. a video to their YouTube account, add new images to their Flickr account and such. So basically the scenario would be something like:

  • Client A visits www.mywebsite.com which presents a list of youtube videos or flickr images.
  • The administrator uploads a new video on youtube or uploads new images to his/her flickr account.
  • When the video/images has been uploaded, the www.mywebsite.com gets notified about the changes and updates the lists that Client A is viewing on the fly.

I know this screams for the observer pattern, but I don't think that can be used crossdomain, no? :-)

Another solution would be to make an AJAX call for every X minute to RSS feeds or YouTube/Flickr APIs.

Anyone knows about best practices when developing this? Any help/hint will be greatly appreciated.

Josh Darnell
  • 11,304
  • 9
  • 38
  • 66
bomortensen
  • 3,346
  • 10
  • 53
  • 74

1 Answers1

1

Schedule some kind of task that reads the RSS/API and populates the database with the new information.

The page does an AJAX request periodically checking for new values in the database (maybe set a read value, or base it off a date time of the last check), and AJAX'es the magic onto the page.

Theres no reason why the AJAX couldn't schedule the RSS/API check, but I doubt that would scale.

Ideally, I'd write a service outside of ASP.NET that would do that check, and just populate the database with the results.

Jroc
  • 488
  • 2
  • 11
  • Hi Jroc, thanks for your answer! :) I was actually thinking of simply setting up a JS infinite timer whenever a client hits the page that makes an AJAX call to the RSS/API every 5th second or so, but not sure if it's best practice. Makes for a lot of calls! I see no reason to store the YT/Flicker data in a database though, but that's just me :) – bomortensen Feb 03 '12 at 14:02
  • Perhaps if every user is unique, in that they are all tracking different sets of youtube/flicker feeds, then maybe you could do without the database middle man. Otherwise caching the data locally would be my choice since you'd have much faster load times for that data – Jroc Feb 03 '12 at 14:26
  • I agree, Jroc :) The visitors will not be unique in the sense that they should all see the same content. So I think caching will be a good call here! Thanks a lot for your input, it's always nice to share knowledge and best practices. – bomortensen Feb 03 '12 at 15:16
  • Depending on how frequently you are polling your server and how many users your site has this solution could be massively inefficient. A more efficient solution would be to use a push technology which would push a notification to interested clients only when there is new data available. I'd recommend having a look at some [realtime web technologies](http://www.leggetter.co.uk/real-time-web-technologies-guide) which are likely to be way more efficient in addition to improve the experience of the website users. – leggetter Feb 03 '12 at 21:00