Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

How do FaceBook updates work?

  • 08-12-2011 11:05pm
    #1
    Closed Accounts Posts: 159 ✭✭


    How do FaceBook updates work?

    When browsing the FB homepage. Updates appear dynamically, you get the text blocks refreshing and the status updating. How is this happening if no http request was sent?


Comments

  • Registered Users, Registered Users 2 Posts: 3,078 ✭✭✭onemorechance


    AJAX.


  • Closed Accounts Posts: 159 ✭✭yenoah


    But that would still have to request data no? via the XmlHttpRequest object ?? Isnt AJAX just about updating parts of a page rather than an entire postback?

    So my question still remains. How does FB update the page dynamically without the user requesting the update?


  • Registered Users, Registered Users 2 Posts: 2,040 ✭✭✭Colonel Panic


    At a guess, setTimeout or setInterval? It just looks dynamic, it's polling with javascript and some callback function.


  • Registered Users, Registered Users 2 Posts: 3,078 ✭✭✭onemorechance


    yenoah wrote: »
    But that would still have to request data no? via the XmlHttpRequest object ?? Isnt AJAX just about updating parts of a page rather than an entire postback?

    So my question still remains. How does FB update the page dynamically without the user requesting the update?

    BigPipe or facebook Ajaxified


  • Registered Users, Registered Users 2 Posts: 11,989 ✭✭✭✭Giblet



    BigPipe is batching flush requests, it's possible to do that in any modern web framework, although it can be a pain in the arse! (Try it, turn off buffered output in .net, then turn it on before you render large controls, then off again after you flush.)

    Basically they have a timer on the page which runs at a set interval to check for updates.


  • Advertisement
  • Closed Accounts Posts: 159 ✭✭yenoah



    Can't see it. Having read the BigPipe article, all I can deduce is that it is used to divide a page into sections, each section can do server round trips in parrallel. Nothing about dynamic updates. Glanced over the Ajazified page and can't see anything about dynamic updates either.

    I see Gilbert has posted that a page runs a timer that checks for updates regularly. If that's the case then that makes sense but I'd love to hear from anyone else who might confirm or deny.


  • Registered Users, Registered Users 2 Posts: 11,989 ✭✭✭✭Giblet


    Use firebug for firefox, or dev tools for chrome and all will be revealed ;)


  • Closed Accounts Posts: 159 ✭✭yenoah


    Giblet wrote: »
    Use firebug for firefox, or dev tools for chrome and all will be revealed ;)

    so you are saying that Facebook updates are browser specific? whhat about IE?


  • Registered Users, Registered Users 2 Posts: 2,040 ✭✭✭Colonel Panic


    What's to confirm or deny? That's pretty much how it's done. Look at the source yourself!

    Anyway, I put breakpoints on the Timer event listeners in the Chrome Dev Tools and indeed it breaks a LOT.

    184466.png


  • Closed Accounts Posts: 159 ✭✭yenoah


    Thanks Gilbert and Colonel Panic.

    So the answer is a javascript timer looping in the client. Does that make FB hard on resources? memory? bandwidth?


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 2,040 ✭✭✭Colonel Panic


    In a modern browser, not especially.


  • Registered Users, Registered Users 2 Posts: 11,989 ✭✭✭✭Giblet


    It's not an especially tight loop, so it's not terrible. It makes the state a little hard to determine though, and page integrity can fall apart in some cases.


  • Registered Users, Registered Users 2 Posts: 1,311 ✭✭✭Procasinator


    Have a look at:
    http://www.facebook.com/note.php?note_id=14218138919

    This can be done though various techniques, Wikipedia gives a good overview:
    http://en.wikipedia.org/wiki/Push_technology

    I would hazard a guess though that most people use either traditional polling or long polling.


  • Registered Users, Registered Users 2 Posts: 3,078 ✭✭✭onemorechance


    yenoah wrote: »
    Thanks Gilbert and Colonel Panic.

    So the answer is a javascript timer looping in the client. Does that make FB hard on resources? memory? bandwidth?

    Your question was how, not when.

    "How is this happening if no http request was sent?"

    An HTTP request is sent. The timer dictates when updates are requested; an XMLHttpRequest is how they are requested. This forms part of the AJAX web development technique, which is how "updates appear dynamically".


  • Closed Accounts Posts: 159 ✭✭yenoah


    Your question was how, not when.

    "How is this happening if no http request was sent?"

    An HTTP request is sent. The timer dictates when updates are requested; an XMLHttpRequest is how they are requested. This forms part of the AJAX web development technique, which is how "updates appear dynamically".

    eh? have we not already sorthed this?

    Requests for updates are sent by a timer in the client. Yes?


  • Registered Users, Registered Users 2 Posts: 3,078 ✭✭✭onemorechance


    yenoah wrote: »
    eh? have we not already sorthed this?

    Requests for updates are sent by a timer in the client. Yes?

    No, they are sent by XmlHttpRequest.


  • Closed Accounts Posts: 159 ✭✭yenoah


    No, they are sent by XmlHttpRequest.


    yea, that's assumed. But I was wondering how the requests were triggered. Answer = timer loop.


  • Registered Users, Registered Users 2 Posts: 3,078 ✭✭✭onemorechance


    yenoah wrote: »
    How is this happening if no http request was sent?
    yenoah wrote: »
    yea, that's assumed. But I was wondering how the requests were triggered. Answer = timer loop.

    OK, I assumed from your first post it was not.


  • Closed Accounts Posts: 2,616 ✭✭✭8k2q1gfcz9s5d4


    yenoah wrote: »
    Nothing about dynamic updates

    pretty sure FB doesnt have dynamic updates, it just updates every 60 seconds or so.


  • Closed Accounts Posts: 18,163 ✭✭✭✭Liam Byrne


    yenoah wrote: »
    Nothing about dynamic updates

    pretty sure FB doesnt have dynamic updates, it just updates every 60 seconds or so.

    That is dynamic updating.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 11,989 ✭✭✭✭Giblet


    Probably means dynamic as in proper pushing rather than static interval


Advertisement