Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the rationale behind the HTTP Date header?

Tags:

date

http

header

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').

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

like image 581
Boldewyn Avatar asked Oct 22 '09 22:10

Boldewyn


People also ask

What is the date header in HTTP?

The Date property represents the value of a Date HTTP header on an HTTP response. The Date header is the date and time the message was sent. Javascript and . NET languages do not use the DateTime object directly.

What is the function of date in HTTP request?

The Date general HTTP header contains the date and time at which the message originated.

What is the purpose of HTTP headers?

An HTTP header is a field of an HTTP request or response that passes additional context and metadata about the request or response. For example, a request message can use headers to indicate it's preferred media formats, while a response can use header to indicate the media format of the returned body.

Is HTTP date header required?

An origin server MUST NOT send a Date header field if it does not have a clock capable of providing a reasonable approximation of the current instance in Coordinated Universal Time. An origin server MAY send a Date header field if the response is in the 1xx (Informational) or 5xx (Server Error) class of status codes.


1 Answers

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_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

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; 
like image 105
Jonathan Feinberg Avatar answered Sep 29 '22 00:09

Jonathan Feinberg