Welcome to WebmasterWorld Guest from 23.22.206.103

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Facebook chat doesn't have to reload on every page change?

How is this possible?

     
2:35 am on Sep 1, 2010 (gmt 0)

Junior Member

10+ Year Member

joined:July 28, 2006
posts: 168
votes: 0


How is it possible that when you have Facebook chat open (in the browser), when you continue to navigate Facebook it the chat never goes away? It's all in the same window. Do they control the load order or something to make it seem like it never went away?
5:03 pm on Sept 1, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 24, 2005
posts:697
votes: 0


iframe ?
7:24 pm on Sept 1, 2010 (gmt 0)

Junior Member

10+ Year Member

joined:July 28, 2006
posts:168
votes: 0


no it doesn't look like an iframe. i think they order the loading starting with the chat. And probably have some crazy caching going on with the rest of the page so the load is minimal.
8:20 pm on Sept 1, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Dec 15, 2003
posts:2606
votes: 0


It's using Ajax logic.
5:56 pm on Sept 8, 2010 (gmt 0)

Junior Member

10+ Year Member

joined:July 1, 2005
posts:191
votes: 0


It's actually much simpler:
[stackoverflow.com...]

The "links" on the main page are not real <a> links, but rather javascript links that trigger a change in the page's content via AJAX. That way, no page reload needs to be done and the chat can stay wherever it is. You basically stay on the same page and reload it's content when you click on links.
7:21 pm on Sept 8, 2010 (gmt 0)

Junior Member

5+ Year Member

joined:Feb 26, 2010
posts:74
votes: 0


i have a follow-up question wrt chats. what is the basic structure of a chat? is it a table in a db maintained for a certain period of time? is it a temporary website created?

have had some trouble wrapping my head around this.
3:12 am on Sept 10, 2010 (gmt 0)

Full Member

5+ Year Member

joined:July 13, 2007
posts:235
votes: 0


I've implemented a few of these. There's actually several ways you can go as far as data storage. Databases are probably the most flexible and easy-to-use, but careful construction of the table and database itself are necessary to prevent the Bottleneck to End All Bottlenecks in high-traffic systems.

A quick and easy alternative is a simple text file, one for each chat "room" for each user. Using PHP logic, append whatever messages come in onto the end of this file. In your AJAX update logic, when a particular user's browser checks for updates, send the contents of the file downstream to the user and empty it. This does not store chat histories, but it does allow a relatively simple (if hard-disk intensive) file-based implementation.