/ HTTP Headers

Accept-Datetime

The Accept-Datetime HTTP header is a crucial part of the HTTP protocol, specifically for web resources that have multiple temporal versions available. It allows clients to request a specific version of a resource as it appeared at a certain point in time.

The Purpose of Accept-Datetime

This request header is used in Memento, a protocol extension for accessing past states of a web resource, also known as “mementos”. When a client sends an Accept-Datetime header, it’s asking the server for the version of the resource as it appeared closest to the specified date and time.

Syntax

The Accept-Datetime header uses the following syntax:

Accept-Datetime: <date-time>

Here, <date-time> is a HTTP-date timestamp, formatted according to the date and time specification outlined in RFC 7231.

How it Works: Request and Response

To understand the Accept-Datetime header’s operation, let’s explore its usage in a typical request/response exchange:

Request

Suppose a client is looking for a version of a web resource as it appeared at 12:00:00 PM on March 1, 2023. It might send a request like this:

GET /document HTTP/1.1
Host: example.com
Accept-Datetime: Wed, 01 Mar 2023 12:00:00 GMT

In this request, the client expresses a desire to receive the version of /document as it existed at the specified date and time.

Response

The server uses the Accept-Datetime header to determine the appropriate version of the resource to send back. The server’s response will include a Memento-Datetime header indicating the actual date and time of the returned resource version.

Here’s an example response to the above request:

HTTP/1.1 200 OK
Memento-Datetime: Wed, 01 Mar 2023 12:00:00 GMT
Content-Type: text/html

<!DOCTYPE html>
...
</html>

In this response, the server confirms that it’s delivering the version of the resource from the requested time.

Compatibility

The Accept-Datetime header is part of the Memento protocol, which is an extension to HTTP rather than part of the core HTTP protocol. Therefore, its support is not universal across all browsers and servers. Web servers need to implement the Memento protocol to support this header.

Summary

The Accept-Datetime HTTP header is a powerful tool for accessing historical versions of a web resource. Although its usage is more niche and not as widespread as other HTTP headers, it’s integral for web archiving and time-based content negotiation. When dealing with temporal resources, it’s important to understand the implications and utility of the Accept-Datetime header in the HTTP request-response lifecycle.

Was this helpful?

Thanks for your feedback!