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 标头 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 值似乎是正确的,为什么我们应该在corrected_received_age 上加 4?只是考虑到任何可能的时钟偏差?我错过了什么吗?