我已阅读 RFC 2616 ,但仍然我想知道,Date字段的用途是什么。有一个Last-Modified字段,除了提供元数据之外,实际上还有一个含义,即用于缓存('If-Modified-Since')。

但有什么用它可以在单独的Date标题中加倍信息?

有帮助吗?

解决方案

根据规范,它用于年龄计算。如果您不知道服务器认为它是什么时间,您将无法计算“年龄”。资源。以下是规范中的相关文字:

  

年龄计算算法摘要,当缓存收到响应时:

     

<强> <代码> age_value 结果         是缓存接收的Age:标头的值                 这个回应。

     

<强> <代码> DATE_VALUE 结果         是原始服务器的 Date:标题

的值      

<强> <代码> REQUEST_TIME 结果         是缓存发出请求的(本地)时间                 这导致了这个缓存的响应

     

<强> <代码> response_time 结果         是缓存收到的(本地)时间                 响应

     

<强> <代码>现在 结果         是当前(本地)时间

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;
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top