天天看點

Nginx中gzip和Content-Length

今天用戶端發現下載下傳檔案進度條無法顯示,開發人員是根據Content-Length來擷取檔案大小的。我們有兩台伺服器對外提供檔案下載下傳,其中一台是正常的。比較寫的nginx子產品這一部分程式完全一緻,仔細檢查標頭資訊,發現兩個標頭中不一緻的部分:

[quote]

HTTP/1.1 200 OK

Server: nginx/0.7.65

Date: Tue, 16 Nov 2010 03:39:28 GMT

Content-Type: text/plain

Connection: keep-alive

Content-Length: 333570

Length: 333570

Content-Range: bytes 0-333569/333570

[/quote]

[quote]

HTTP/1.1 200 OK

Server: nginx/0.7.65

Date: Tue, 16 Nov 2010 03:42:11 GMT

Content-Type: text/plain

Transfer-Encoding: chunked

Connection: keep-alive

Vary: Accept-Encoding

Length: 68020

Content-Range: bytes 0-68019/68020

Content-Encoding: gzip

[/quote]

原來是因為一天修改了其中一台伺服器的配置,打開了gzip後Content-Length字段就沒有了。

繼續閱讀