jQueryでKeep-Aliveされない問題
ErlangでCometのサンプルを利用されている方から,Connection: close になっているよ,との指摘をいただいた.
で,早速調べてみると,IE・FirefoxではKeep-Aliveだが,Firefoxではcloseになってしまう.
ブラウザ側がリクエストするときに,Connection: close をつけているので,サーバ側の問題ではないようだ.
jQueryのソースを見てみると,
// Make sure the browser sends the right content length
if ( xml.overrideMimeType )
xml.setRequestHeader("Connection", "close");
というコードがあった.
ぐぐってみると,prototype.jsでも同様の処理がある模様.
/* Force "Connection: close" for Mozilla browsers to work around
* a bug where XMLHttpReqeuest sends an incorrect Content-length
* header. See Mozilla Bugzilla #246651.
*/
if (this.transport.overrideMimeType)
requestHeaders.push('Connection', 'close');
とあるので,必要な対策っぽい.
ただ,該当バグは
Bug 246651 – XMLHttpRequest doesn't calculate Content-Length correctly
でもうcloseされているので,1年前には直っている模様.
Keep-Aliveが使えないと,Firewallの負荷などをあげてしまいそうだけど,どっちをとるかだなぁ.
古いブラウザは知らないよ,と言えるなら,Keep-Aliveにできそうだ.
ただ,prototype.jsもjQuery.jsもこの対策をとっているということは,そういうユーザも少なからずいる,ってことなんだろうなぁ.うーむ.
Comments