1,前cdn域名和后cdn域名列表
video.xx.com(前) xx.qiniu.cloudcdn.net(后)
audio.xx.com(钱) xx.qiniu.cloudcdn.net(后)
2,切换要测试条目
1.m3u8 不缓存;
2.回源鉴权,返回缓存;
3.过期、不争取token报 401
3,测试ping到的节点。方便加host来测试
liuhanlindemac:private yishiyaonie$ ping fcdbig.qiniu.cloudcdn.net
PING c01.i07.ctlshqn2.lv3.cloudglb.com (122.228.193.89): 56 data bytes
64 bytes from 122.228.193.89: icmp_seq=0 ttl=51 time=13.811 ms
64 bytes from 122.228.193.89: icmp_seq=1 ttl=51 time=13.814 ms
可以看到ping到的节点是:122.228.193.89
4,首先测试m3u8不缓存。
这个测试起来简单。因为私有资源,每次签名时间变了。m3u8里面的链接也就改变了。相当于m3u8的内容改变了,看下是否是同一个etag就能验证。
生成一条下载链接测试:
liuhanlindemac:private yishiyaonie$ curl -I "http://122.228.193.89/141a1c9c213378e6310c23cc74acc918.m3u8?pm3u8/0/expires/14400&e=1442911336&token=TZyT059uJpbvYeklLS-WaJ4poi4SYia8_lm-nKV8:f-3MNFwe3t1SDVmyrA8dVNzh74Y=" -H "Host:audio.gaiavoicelight.com"
HTTP/1.1 200 OK
Date: Tue, 22 Sep 2015 07:45:59 GMT
Content-Length: 32700
Accept-Ranges: bytes
Content-Type: application/x-mpegurl
Cache-Control: public, max-age=31536000
Connection: Keep-Alive
Etag: "ALjdCt13QvQ6zMWYZsvLtev_N2Ax"
X-Private: 1
Server: nginx/1.4.4
Access-Control-Allow-Origin: *
Access-Control-Max-Age: 2592000
Content-Transfer-Encoding: binary
X-Log: mc.g;FOPAGENT;pm3u8.rsrc:2;pm3u8.rewrite:2;FFMPEG:5;FOPAGENT:7;FOPAGENT;pm3u8.rsrc:2;pm3u8.rewrite:2;FFMPEG:5;FOPAGENT:7;FOPG:8;FOPAGENT;IO:12
X-Reqid: ghIAAM-hBO8kPQYU
X-Qiniu-Zone: 0
Fw-Via: Configured MISS from 122.228.193.86
可以看到:
Content-Length: 32700
Etag: "ALjdCt13QvQ6zMWYZsvLtev_N2Ax"
Fw-Via: Configured MISS from 122.228.193.86
然后我再生成一个链接
liuhanlindemac:private yishiyaonie$ curl -I "http://122.228.193.89/141a1c9c213378e6310c23cc74acc918.m3u8?pm3u8/0/expires/144000&e=1442911781&token=TZyT059uJpbvYeklLS-WaJ4poi4SYia8_lm-nKV8:_TJwf_xC11A0xjcKMk6ARg-s0Vc=" -H "Host:audio.gaiavoicelight.com"
HTTP/1.1 200 OK
Date: Tue, 22 Sep 2015 07:50:44 GMT
Content-Length: 32700
Accept-Ranges: bytes
Content-Type: application/x-mpegurl
Cache-Control: public, max-age=31536000
Connection: Keep-Alive
Etag: "AICzgiNIVSTXEyuLwnDch4GNwqRI"
X-Private: 1
Server: nginx/1.4.4
Access-Control-Allow-Origin: *
Access-Control-Max-Age: 2592000
Content-Transfer-Encoding: binary
X-Log: mc.g;FOPAGENT;pm3u8.rsrc:2;pm3u8.rewrite;FFMPEG:3;FOPAGENT:4;FOPAGENT;pm3u8.rsrc:2;pm3u8.rewrite;FFMPEG:3;FOPAGENT:4;FOPG:6;FOPAGENT;IO:9
X-Reqid: Ul4AAPIDek1nPQYU
X-Qiniu-Zone: 0
Fw-Via: Configured MISS from 122.228.193.86
可以看到
Content-Length: 32700
Etag: "AICzgiNIVSTXEyuLwnDch4GNwqRI"
Fw-Via: Configured MISS from 122.228.193.86
所以确定m3u8不缓存。测试成功。
5,测试ts文件缓存(同样也是查etag)
结合上面测试方法中生成的两个url,分别curl下。找最后的ts文件测试,因为ts没变,链接的访问参数变了。所以应该是去问号缓存的。我们来看下etag。
liuhanlindemac:private yishiyaonie$ curl -I "http://122.228.193.89/UZMp6xzpSs1ftjq7tmK4HM8QT8Q=/ltfpFeYczqxynp3GasM3D_JWyZL-/000152.ts?e=1443052398&token=TZyT059uJpbvYeklLS-WaJ4poi4SYia8_lm-nKV8:86oim5GsmrBMI9XTGTGv5Teov40" -H "Host:7xigxg.com2.z0.glb.qiniucdn.com"
HTTP/1.1 200 OK
Date: Tue, 22 Sep 2015 07:57:33 GMT
Content-Length: 10340
Accept-Ranges: bytes
Content-Type: video/mp2t
Last-Modified: Mon, 25 May 2015 19:22:10 GMT
Cache-Control: public, max-age=31536000
Connection: Keep-Alive
Etag: "FklSMcFEocIO5iMHfdWsHbZU3o29"
X-Private: 1
Server: nginx/1.4.4
Access-Control-Allow-Origin: *
Access-Control-Max-Age: 2592000
Content-Transfer-Encoding: binary
X-Log: mc.g;IO:1
X-Reqid: EGoAAAxkcn7GPQYU
X-Qiniu-Zone: 0
Content-Disposition: inline; filename="000152.ts"
Fw-Via: Configured MISS from 122.228.193.85, Configured MISS from 122.228.193.86
Etag: “FklSMcFEocIO5iMHfdWsHbZU3o29”
另外一个url:
liuhanlindemac:private yishiyaonie$ curl -I "http://122.228.193.89/UZMp6xzpSs1ftjq7tmK4HM8QT8Q=/ltfpFeYczqxynp3GasM3D_JWyZL-/000152.ts?e=1442923164&token=TZyT059uJpbvYeklLS-WaJ4poi4SYia8_lm-nKV8:CCmrP8bFDt7Y3IFKJGLtkar6Gs0" -H "Host:7xigxg.com2.z0.glb.qiniucdn.com"
HTTP/1.1 304 Not Modified
Date: Tue, 22 Sep 2015 08:03:10 GMT
Connection: Close
Fw-Via: DISK HIT NOT MODIFIED from 122.228.193.83, Configured MISS from 122.228.193.86
结果出现304,这个是失败的。因为请求304,需要发请求的时候,告诉服务端已经有本地缓存了。用本地的缓存。需要带一个请求头告诉服务端才可以。