測試環境:
2台虛擬機,分別是192.168.202.130-nginx
192.168.202.129-ats
驗證問題: 允許強制緩存 允許設置緩存時間
驗證過程:
安裝好nginx 開啟 nginx 服務,在配置文件中添加 add_header Cache-Control no-cahe信息,
達到nginx下的文件不緩存的目的,測試結果如下:
HTTP/1.1 200 OK
Server: nginx/1.10.1
Date: Wed, 27 Jul 2016 17:10:46 GMT
Content-Type: image/png
Content-Length: 8133
Last-Modified: Fri, 15 Jul 2016 09:01:24 GMT
Connection: keep-alive
ETag: "5788a664-1fc5"
Cache-Control: no-cache
Accept-Ranges: bytes
測試結果:不緩存 no-cache
安裝好ats服務器,修改records.config如下配置:
CONFIG proxy.config.http.server_ports STRING 80 //端口由默認8080修改為80
CONFIG proxy.config.http.insert_request_via_str INT 3 // 默認為1,通過此值查詢緩存情況
CONFIG proxy.config.http.insert_response_via_str INT 2 //// 默認為0,通過此值查詢緩存情況
CONFIG proxy.config.http.cache.required_headers INT 0 // 默認為2,修改為0
CONFIG proxy.config.cache.ram_cache.size INT 1000 //緩存的空間大小為1000,默認為-1
CONFIG proxy.config.diags.debug.enabled INT 1 // 默認為 0
CONFIG proxy.config.diags.debug.tags STRING http.*|dns.*|cache.* //默認只有dns
然后修改cache.config文檔:
dest_domain=192.168.202.130 ttl-in-cache=86400h //增加一條規則
再次修改remap.config文檔:
map http://192.168.202.129 http://192.168.202.130 //增加一條映射規則
修改完畢,重啟ATS服務器,測試:
HTTP/1.1 200 OK
Server: ATS/6.1.1
Date: Wed, 27 Jul 2016 15:32:08 GMT
Content-Type: image/png
Content-Length: 8133
Last-Modified: Fri, 15 Jul 2016 09:01:24 GMT
ETag: "5788a664-1fc5"
Cache-Control: no-cache
Accept-Ranges: bytes
Age: 6851
Connection: keep-alive
Via: http/1.1 bi (ApacheTrafficServer/6.1.1 [cRs f ])
緩存時間為6851秒,Via信息為:[cRs f ] 經查詢: in cache, fresh Ram hit (a cache "HIT")