[Pro] just curious how they do this..

Hi,

There is a site called www.theguardian.com

I was just wondering how they do a “Live Feed” in the web page. I have 1 on mine using twitter but certainly like theirs better.

I like how it says “12 min ago” and some other things.

Is this something developed by the website designer to allow the reporter to do updates from their phone around the world?

here is the page… the live feed is a little down on the page

Thanks!

Barry


freewaytalk mailing list
email@hidden
Update your subscriptions at:
https://freewaytalk.softpress.com/person/options

The Guardian is a major league UK newspaper and as you can imagine their resources are just a tad larger than yours.

So it is no wonder they can do things a lot better.

If you had their webdev team you wouldn’t be using FW.

D


freewaytalk mailing list
email@hidden
Update your subscriptions at:
https://freewaytalk.softpress.com/person/options

And if you think that you are good enough then the Guardian is Hiring.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
https://freewaytalk.softpress.com/person/options

There’s two basic ways to do this sort of thing: server push or long polling (leave aside Websockets, because they don’t work in older IE, and a major national newspaper would not go that way).

Server push is done using a script on the server to send a portion of the page into the existing page, you can do it with PHP or another server-side language. Server push appends (adds to) the existing page, so if you had a news feed, it would add more news to the bottom of the list.

Long polling is done from the page using JavaScript, you use setInterval or (tail-call setTimeout) to request a partial page, and then update the page with the result. If you go to the home page of FreeCounter http://freewaypro.com/counter2, you will see that on the stats block. If you pay careful attention, you will see the “XXX pixels served” number go up and up as you sit there.

Here’s the script that does this:

if($('hits_list')){
  new Ajax.PeriodicalUpdater('hits_list','/counter2/sites/overview',{method:'get',frequency:8,decay:2});
}

So this requires that you have a script (in this case PHP) on your server that will return just that little block with the updated content every time it is requested. The JavaScript uses the Prototype.js framework and a wickedly simple-looking function called Ajax.PeriodicalUpdater to request the latest content for the #hits_list block (a DIV) every 8 seconds. The decay attribute is a really cool feature, if the return from the server matches exactly what was already in the page, then the decay will add 2 seconds to the time it waits until asking again. This becomes cumulative, but the moment that a new result is returned, the script snaps back to 8 seconds (or whatever you set the frequency to).

Walter

On Sep 13, 2015, at 7:59 PM, DeltaDave email@hidden wrote:

The Guardian is a major league UK newspaper and as you can imagine their resources are just a tad larger than yours.

So it is no wonder they can do things a lot better.

If you had their webdev team you wouldn’t be using FW.

D


freewaytalk mailing list
email@hidden
Update your subscriptions at:
https://freewaytalk.softpress.com/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
https://freewaytalk.softpress.com/person/options

Wow walt. I understood about none of that but impressive.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
https://freewaytalk.softpress.com/person/options