HTTP Date 标头背后的基本原理是什么? [英] What's the rationale behind the HTTP Date header?

查看:20
本文介绍了HTTP Date 标头背后的基本原理是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已阅读 RFC 2616,但仍然我想知道,日期字段是做什么用的.有 Last-Modified 字段,实际上除了提供元数据之外还有其他意义,即用于缓存('If-Modified-Since').

I have read RFC 2616, but still I wonder, what the Date field is for. There is the Last-Modified field, that actually has a meaning besides just serving metadata, that is, for caching ('If-Modified-Since').

但是将单独的 Date 标头中的信息加倍有什么用呢?

But what use has it to double the info in a separate Date header?

推荐答案

根据 规范,用于年龄计算.如果您不知道服务器认为现在是什么时间,您将无法计算年龄".的一种资源.以下是规范中的相关文本:

Per the spec, it is used in age calculations. If you don't know what time the server thinks it is, you won't be able to calculate the "age" of a resource. Here's the relevant text from the spec:

年龄计算算法总结,当缓存收到响应时:

Summary of age calculation algorithm, when a cache receives a response:

年龄值
是 Age: 缓存接收到的标头的值这个回应.

age_value
is the value of Age: header received by the cache with this response.

date_value
是源服务器的 Date: header

request_time
是缓存发出请求的(本地)时间这导致了这个缓存的响应

request_time
is the (local) time when the cache made the request that resulted in this cached response

response_time
是缓存接收到的(本地)时间回应

response_time
is the (local) time when the cache received the response

现在
是当前(本地)时间

now
is the current (local) 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;

这篇关于HTTP Date 标头背后的基本原理是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆