nginx代理,斷點續傳測試。

原文:

nginx配置見原文

關於HTTP請求頭range的說明:

http://www.iwms.net/n2030c40.aspx

請求測試:

wget -SO /dev/null --header="X-Backend: download.thinkbroadband.com" --header="X-Backend-Port: 80" --header="Range: bytes=50-" localhost/5MB.zip
--2013-07-02 22:43:30--  http://localhost/5MB.zip
Resolving localhost... 127.0.0.1, ::1
Connecting to localhost|127.0.0.1|:80... connected.
HTTP request sent, awaiting response...
 HTTP/1.1 200 OK
 Server: nginx/0.8.54
 Date: Tue, 02 Jul 2013 14:43:31 GMT
 Content-Type: application/zip
 Connection: keep-alive
 Last-Modified: Mon, 02 Jun 2008 15:30:42 GMT
 ETag: "11f000b-500000-44eb0adaf4c80"
 Accept-Ranges: bytes
 Content-Length: 5242880
 Access-Control-Allow-Origin: *
 X-Cached: MISS
Length: 5242880 (5.0M) [application/zip]
Saving to: `/dev/null'

100%[==========================================================================================>] 5,242,880    638K/s   in 11s    

2013-07-02 22:43:43 (453 KB/s) - `/dev/null' saved [5242880/5242880]

第一次請求時nginx代理上還沒有文件的緩存,所以cache miss,代理服務器會全部保存到緩存。

root@wangyangtest:/var/cache/nginx# ls
07
root@wangyangtest:/var/cache/nginx# ll 07/a6/a3/ac136536ba7bb4171654401eb2a3a607

-rw-------  1 nobody  wheel  5243220 Jul  2 22:43 07/a6/a3/ac136536ba7bb4171654401eb2a3a607

發起續傳請求:

root@wangyangtest:/var/cache/nginx# wget -SO /dev/null --header="X-Backend: download.thinkbroadband.com" --header="X-Backend-Port: 80" --header="Range: bytes=50-" localhost/5MB.zip
--2013-07-02 22:43:48--  http://localhost/5MB.zip
Resolving localhost... 127.0.0.1, ::1
Connecting to localhost|127.0.0.1|:80... connected.
HTTP request sent, awaiting response...
 HTTP/1.1 206 Partial Content
 Server: nginx/0.8.54
 Date: Tue, 02 Jul 2013 14:43:48 GMT
 Content-Type: application/zip
 Content-Length: 5242830
 Connection: keep-alive
 Last-Modified: Mon, 02 Jun 2008 15:30:42 GMT
 ETag: "11f000b-500000-44eb0adaf4c80"
 Access-Control-Allow-Origin: *
 X-Cached: HIT
 Content-Range: bytes 50-5242879/5242880

客戶端再次發起續傳請求,首先要檢查Cached,如果命中則正常返回206續傳


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章