Welcome to WebmasterWorld Guest from

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)

5+ Year Member

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 Sep 1, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

iframe ?


7:24 pm on Sep 1, 2010 (gmt 0)

5+ Year Member

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 Sep 1, 2010 (gmt 0)

WebmasterWorld Senior Member demaestro is a WebmasterWorld Top Contributor of All Time 10+ Year Member

It's using Ajax logic.


5:56 pm on Sep 8, 2010 (gmt 0)

10+ Year Member

It's actually much simpler:

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 Sep 8, 2010 (gmt 0)

5+ Year Member

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 Sep 10, 2010 (gmt 0)

5+ Year Member

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.

Featured Threads

Hot Threads This Week

Hot Threads This Month