selphon 发表于 2013-04-02 22:29

traffic server freshness_limit试用

ats的官方文档说,当没有Expires或max-age头的情况下,ats会根据date, last_modified以及heuristic_lm_factor计算过期时间。

ats中相关配置如下:
CONFIG proxy.config.http.cache.heuristic_min_lifetime INT 3600
CONFIG proxy.config.http.cache.heuristic_max_lifetime INT 86400
CONFIG proxy.config.http.cache.heuristic_lm_factor FLOAT 0.100000

然后在源站创建文件pnow.jpg, 发起请求:
# wget -S --header "Host:test.ats.com" http://127.0.0.1/pnow.jpg?t1 -P /tmp/
--2013-04-02 22:17:09--http://127.0.0.1/pnow.jpg?t1
Connecting to 127.0.0.1:80... connected.
HTTP request sent, awaiting response...
HTTP/1.0 200 OK
Server: ATS/3.2.4
Date: Tue, 02 Apr 2013 14:17:09 GMT
Content-Type: image/jpeg
Content-Length: 483632
Last-Modified: Tue, 02 Apr 2013 14:00:00 GMT
Accept-Ranges: bytes
Age: 0
Connection: keep-alive
Length: 483632 (472K)
Saving to: `/tmp/pnow.jpg?t1.6'

100%[===================================================================================>] 483,632   --.-K/s   in 0.002s

然而无论多少次请求,Age始终是0,源站有回源记录。
本次测试中,Last-Modified时间是 Tue, 02 Apr 2013 14:00:00 GMT, 请求date在这之后10~15分钟期间,根据freshness_limit = ( date - last_modified ) * 0.10的公式,在1~1.5分钟期间应该是fresh的,为什么实测看到的是没有缓存而回源了呢?

ats初学者,求解答。

selphon 发表于 2013-04-02 22:52

找到原因了,修改proxy.config.http.cache.required_headers值为0, 原先为2, 只缓存带expires和max-age头的对象。

# wget -S --header "Host:test.ats.com" http://127.0.0.1/pnow.jpg?t14 -P /tmp/
--2013-04-02 22:48:38--http://127.0.0.1/pnow.jpg?t14
Connecting to 127.0.0.1:80... connected.
HTTP request sent, awaiting response...
HTTP/1.0 200 OK
Server: ATS/3.2.4
Date: Tue, 02 Apr 2013 14:41:37 GMT
Content-Type: image/jpeg
Content-Length: 483632
Last-Modified: Tue, 02 Apr 2013 14:30:00 GMT
Accept-Ranges: bytes
Age: 421
Connection: keep-alive
Length: 483632 (472K)
Saving to: `/tmp/pnow.jpg?t14.175'

100%[===================================================================================>] 483,632   --.-K/s   in 0.002s

2013-04-02 22:48:38 (288 MB/s) - `/tmp/pnow.jpg?t14.175' saved

但依照上述Date, Last-modified, 我计算出的缓存时间是(14:41:37 - 14:30:30) * 0.1 = 1 分钟, 为什么现在已经421s了还是fresh的?
页: [1]
查看完整版本: traffic server freshness_limit试用