• Search
  • Member List
  • Help
  • Random Thread

  • Tech Discussion The latest threads panel. reg.
    I have a question on how RC's Latest Threads panel (on the left side of the screen below ''Who's online') is automatically updated, when a user makes a post in a thread.

    It is as though content is pushed to the browser, rather than pulled by the browser which is the way I've known things to work.

    To test, I opened RCF homepage on two tabs in IE 11.
    I added a post in an existing thread and lo it was refreshed immediately in the other tab of the browser.

    How does this magic happen please ?
    Thank you. :-)

    Edit: It didn't happen for this new thread however.
    (This post was last modified: 04-20-2015, 11:18 AM by radiobox.)

    Progress might have been all right once, but it has gone on too long -- Ogden Nash
    wildcard liked this post
    The auto-refresh for the latest threads, who's online and other side boxes is made possible by a little thing called AJAX.

    Basically, it uses JavaScript (which runs on the browser side) to request information from PHP (which runs on the server side). So basically, every x amount of seconds (30 for latest threads, 60 for Who's Online) the browser polls the database to see if new threads have been created, or old threads have new posts, and if so, refreshes the side boxes.

    For more info, read this thread: https://www.rantcentralforums.com/Thread...to-Refresh

    Sometimes (like in the example you mentioned) it seems like it happens instantly, but it is important to note that the counter starts when the page is initially loaded. So if you've been viewing the page for 28 seconds and you post in another tab it will appear very quickly.
    Nice. Mystery solved. Thank you WC. :-)

    Is there a way a user can configure the refresh interval (Am guessing it's a No). 30 seconds seems a bit frequent. My usage for instance is capped at a certain number of GB per month (for max speed after which the speed drops). So, if I were to be online 1 hour a day (avg) will the montly data usage amount to a significant number of bytes. Am guessing not. Even 10 MB per month is ok. Am charged btw, only for received bytes.

    Also, is this the method used in forum 'Shoutboxes' as well ?

    Edit: Did a very rough calculation. 2*60*24*30 = 86400 (!) queries per month. With a reply size of say 200 Bytes, it comes to 17 MB ?! That's an extreme case. Am not online on home page for 1 hour, maybe 1/2 hour max. So that's just 8 MB. Cool. (Hope I haven't made a Sheldonesque calculation mistake)
    (This post was last modified: 04-20-2015, 11:44 PM by radiobox.)

    Progress might have been all right once, but it has gone on too long -- Ogden Nash
    simpler to close the tab when you're not using it.
    (04-20-2015, 10:34 PM)radiobox Wrote:  (Hope I haven't made a Sheldonesque calculation mistake)

    To figure the bandwidth usage, the formula would be as followed:

    S = total time on the RC front page in seconds
    P = page data size

    (S / 30) * P = Total Data Used

    The thing to keep in mind is that when I decided to use AJAX to talk to the server after page load for auto-refresh, I considered not only the load it would create on our servers, but also the effect it would have on the end-user's bandwidth. So I kept everything to a bare minimum.

    The code on the server side could take a year to finish and it wouldn't affect your bandwidth, but anything that is output is data that you have to download.

    So instead of refreshing the entire page, the side box containing the latest threads (or whichever) module is simply updated.
    Thanks WC for elaborating. The side box shall always stay open. :-)

    Progress might have been all right once, but it has gone on too long -- Ogden Nash
    (04-21-2015, 11:08 PM)radiobox Wrote:  The side box shall always stay open. :-)

    You made me remember another detail, if the latest threads side box is minimized it won't refresh and no request is made to the server.

    (04-21-2015, 11:08 PM)radiobox Wrote:  Thanks WC for elaborating.

    No problem. I love talking about this shit Big Grin

    Users browsing this thread: 2 Guest(s)
    Rant Central
    Speak Your Mind