Webserver push tới browser (client), kỹ thuật và đánh giá, Reverse Ajax / Comet / Ajax Push

(đang nghiên cứu và đánh giá, thực hiện)

Giới thiệu công nghệ

Reverse Ajax refers to an Ajax design pattern that uses long-lived HTTP connections to enable low-latency communication between a web server and a browser. Basically it is a way of sending data from client to server and a mechanism for pushing server data back to the browser.[1][2]

This server–client communication takes one of two forms:

* Client polling, the client repetitively queries (polls) the server and waits for an answer.
* Server pushing, a connection between a server and client is kept open, the server sends data when available.

Reverse Ajax describes the implementation of any of these models, including a combination of both. The design pattern is also known as Ajax Push, Full Duplex Ajax and Streaming Ajax.

Từ khoá: Reverse Ajax / Comet / Ajax Push

Slow load

http://www.obviously.com/tech_tips/slow_load_technique

So sánh Push và Pull khi dùng Ajax

http://www.infoq.com/news/2007/07/pushvspull

Các lựa chọn để cài đặt

Comet – http://cometdproject.dojotoolkit.org/

Cometd Bayeux Ajax Push: Cometd is a scalable HTTP-based event routing bus that uses a Ajax Push technology pattern known as Comet. The term ‘Comet’ was coined by Alex Russell in his post Comet: Low Latency Data for the Browser.

MeteorServer – http://meteorserver.org/

jquery

dojo

APE  http://www.ape-project.org/

Tomcat / Pushlets

http://www.pushlets.com/

http://www.icesoft.com/corporate/press_release_07_06_EE_1.0.html

http://www.icefaces.org/main/ajax-java/ajaxpush.iface

Apache

http://jha.rajeev.googlepages.com/web2push

PHP server push (chỉ xài với non-IE)
http://web.they.org/software/php-push.php

Đọc thêm

http://www.wired.com/wired/archive/5.03/ff_push_pr.html

http://www.patentstorm.us/patents/6381645/claims.html

http://www.itaware.eu/2008/11/03/push-push-push-on-the-browser/

http://www.itaware.eu/2008/11/03/push-push-push-on-the-browser/

http://www.openajax.org/member/wiki/Main_Page

http://www.theserverside.com/news/thread.tss?thread_id=40650

http://ajaxpatterns.org/HTTP_Streaming

http://cometdaily.com/

http://www.pathf.com/blogs/2006/05/not_there_yet_c/

Jetty 6 Servlet Container has it. It is called Continuation and is based on NIO

Scalability is a fundamental feature for a Comet Server, since a large number of concurrent TCP connections has to handled.
Lightstreamer is based on a staged event driven architecture, built over Java NIO classes, that allows it to handle an arbitrary number of connections with a fixed pool of threads.
Just to give you an idea of performance, on a single Pentium 4 CPU – 2.4 GHz, Lightstreamer Server was able to sustain 10,000 concurrent streaming connections with an outbound frequency of 1 update/sec per client.

.NET
http://www.codeproject.com/KB/aspnet/CometGrid.aspx?fid=1538113&select=3001476#xx3001476xx
http://www.codeproject.com/KB/aspnet/CometMultiClient.aspx

Advertisements

Cache control problem with IE6 when do Ajax site call XML API

When create ajax site, we let client browser use js to make some call to our API services (REST). API function return output as XML (our format). Then the js at browser parse the return XML to display some fancy on screen.

Firefox, Mozzila base work fine, but IE6 is so stupid and lazy. IE6 cache the return XML data, and later call to API (with the same URL), IE6 take data from it internal cache, avoid calling from API.

To avoid it, our API server must send some header(s), tell the browser (client) NOT TO CACHE the XML data (fetching from API). You must do it from SERVER, remember.

Here is correct sequence (write in PHP), work for IE6

header(“Expires: Mon, 26 Jul 1997 05:00:00 GMT”);
header(“Last-Modified: ” . gmdate(“D, d M Y H:i:s”) . ” GMT”);
header(“Cache-Control: no-store, no-cache, must-revalidate”);
header(“Cache-Control: post-check=0, pre-check=0”, false);
session_start();
header(“Cache-Control: private”);

But, beside the problem with IE (while using js, make ajax call to XML file), using caching with API oriented and ajax call is very sweet.

Some resource I found here about caching:

http://www.htaccesselite.com/using-php-header-function-vt156.html
http://www.phpbuilder.com/board/showthread.php?t=10294526
http://www.websiteoptimization.com/speed/tweak/cache/
http://www.chriskirkland.net/news/59_PHP-Cache-Control-script.html
http://www.badpenguin.org/docs/php-cache.html
http://www.mnot.net/cache_docs/
http://www.htaccesselite.com/using-php-header-function-vt156.html