为什么有必要在HTTP年龄计算中为纠正的接收年龄添加响应延迟?

时间:2013-06-11 13:49:16

标签: http caching

RFC 2616 Sec 13.2.3提供以下年龄计算算法:

apparent_age = max(0, response_time - date_value);
corrected_received_age = max(apparent_age, age_value);
response_delay = response_time - request_time;
corrected_initial_age = corrected_received_age + response_delay;
resident_time = now - response_time;
current_age   = corrected_initial_age + resident_time; 

Where

age_value: is the value of Age: header received by the cache with this response.
date_value: is the value of the origin server's Date: header
request_time: is the (local) time when the cache made the request that resulted in this cached response
response_time: is the (local) time when the cache received the response
now: is the current (local) time

我的问题是,为什么有必要将response_delay添加到corrected_initial_age?

我的理解是response_time - date_value已经包含生成响应和收到响应之间的延迟,因此如果我们添加response_delay,那么我们还包括生成请求和服务器接收请求之间的时间。

例如,如果客户端在时间0(request_time = 0)发送请求,则在时间4(response_time = 4)接收响应(没有Age header age_value = 0)并且日期标头是2(date_value = 2)。

apparent_age = max(0, 4 - 2) = 2
corrected_received_age = max(2, 0) = 2
response_delay = 4 - 0 = 4
corrected_initial_age = 2 + 4 = 6
resident_time = 8 - 4 = 4
current_age = 6 + 4 = 10 

如果aparent_age值似乎正确,我们为什么要将correct_received_age添加4?它只是考虑到任何可能的时钟偏差?我错过了什么吗?

1 个答案:

答案 0 :(得分:2)

即将发布的RFC 2616修订版将调整该算法,详见http://greenbytes.de/tech/webdav/draft-ietf-httpbis-p6-cache-22.html#age.calculations