Do you know how Google Docs Javascript automatically updates interval data?

Ok, here it is:

I am currently implementing software that autorefresh / autopull / autoreload data to support real-time screen using AJAX.

This really works, but I know that I used the easiest way:

  • SetInterval (javascript)
  • Call the update method in seconds.
  • Read the Json Data, rebuild the HTML and update it.

You can also do this by simply calling SetTimeOut (javascript) and the end of the AJAX request.

In the update method, I internally verify that it is not being called at the same time, etc.

However ... this is the easiest approach, it works, but on slow firefox computers, etc., I see that this action sometimes freezes the browser, and I know that this may not be necessary due to an AJAX call, but how "intensive" is a javascript operation in general ... but, after starting the profiler, general javascript (using jquery by the way) seems to be in order. Also, if I turn off autorefresh, the browser will not freeze for short seconds on slow computers.

I decided to research how some of the major AJAX applications work.

Facebook, for example, they make a request all the time, every N seconds, interpret JSON and update the screen, but google docs ... I can find any request. Perhaps this is because: are they just telling the javascript debugger engine that they don't want their request to be logged? Or do they take a different approach to the update dilemma?

I read in another answer here on stackoverflow that Google Docs support an open connection.

Could this be the answer? http://ajaxpatterns.org/HTTP_Streaming

What do you know about this?

As a great side, the application I'm developing is designed to access thousands of users at a time, and I know that the JavaScript update procedure only tells a small part of the story, but the server-side application and database currently support this kind of load according to the stress tests that I did using several thousand virtualized stations. I just want to know what you think about the client browser problem.

Regards and If you are still reading this. Thank you for your time.

+4
source share
2 answers

I suspect they are using WebSockets . Browser support is uneven, so your mileage may vary depending on this approach.

You can also watch APE (ajax push engine), which is a decent implementation of long polls using the client / server architecture.

+2
source

You can read Long Polling . But then you have to handle dropped connections, etc.

0
source

All Articles