Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(http): Refresh headers docs i-r #36079

Merged
merged 10 commits into from
Oct 24, 2024
57 changes: 26 additions & 31 deletions files/en-us/web/http/headers/if-unmodified-since/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,14 @@ browser-compat: http.headers.If-Unmodified-Since

{{HTTPSidebar}}

The HyperText Transfer Protocol (HTTP) **`If-Unmodified-Since`** request header makes the
request for the resource conditional: the server will send the requested resource or accept it in
the case of a {{HTTPMethod("POST")}} or another non-{{Glossary("Safe/HTTP", "safe")}} method only if the resource has not been modified after the date specified by this HTTP header. If the resource has been modified
after the specified date, the response will be a {{HTTPStatus("412", "412 Precondition Failed")}} error.
The HTTP **`If-Unmodified-Since`** {{glossary("request header")}} makes the request for the resource [conditional](/en-US/docs/Web/HTTP/Conditional_requests).
bsmth marked this conversation as resolved.
Show resolved Hide resolved
The server will send the requested resource (or accept it in the case of a {{HTTPMethod("POST")}} or another non-{{Glossary("Safe/HTTP", "safe")}} method) only if the resource on the server has not been modified after the date in the request header.
If the resource has been modified after the specified date, the response will be a {{HTTPStatus("412", "412 Precondition Failed")}} error.

The **`If-Unmodified-Since`** HTTP header is commonly used in the following situations:
The `If-Unmodified-Since` header is commonly used in the following situations:

- In conjunction with non-{{Glossary("Safe/HTTP", "safe")}} methods, like {{HTTPMethod("POST")}},
this header can be used to implement an [optimistic concurrency control](https://en.wikipedia.org/wiki/Optimistic_concurrency_control), as is done by some wikis: editions are rejected if the
stored document has been modified since the original was retrieved.
- In conjunction with a range request using the {{HTTPHeader("Range")}} header, this header can
be used to ensure that the new fragment requested comes from an unmodified document.
- In conjunction with non-{{Glossary("Safe/HTTP", "safe")}} methods like {{HTTPMethod("POST")}}, this header can be used to implement an [optimistic concurrency control](https://en.wikipedia.org/wiki/Optimistic_concurrency_control), as is done by some wikis: revision are rejected if the stored document has been modified since the original was retrieved, avoiding conflicts.
- In conjunction with a range request using the {{HTTPHeader("Range")}} header, this header can be used to ensure that the new fragment requested comes from an unmodified document.

<table class="properties">
<tbody>
Expand All @@ -28,7 +24,7 @@ The **`If-Unmodified-Since`** HTTP header is commonly used in the following situ
</tr>
<tr>
<th scope="row">{{Glossary("Forbidden header name")}}</th>
<td>no</td>
<td>No</td>
</tr>
</tbody>
</table>
Expand All @@ -41,21 +37,21 @@ If-Unmodified-Since: <day-name>, <day> <month> <year> <hour>:<minute>:<second> G

## Directives

- \<day-name>
- : A 3-letter description of the day of the week. One of "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", or "Sun" (case-sensitive).
- \<day>
- : A 2-digit day number of the month. Examples: "04", "23".
- \<month>
- : A 3-letter description of the month. One of "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" (case-sensitive).
- \<year>
- : A 4-digit year number. Examples: "1990", "2016".
- \<hour>
- : A 2-digit hour number based on a 24-hour system. Examples: "09", "23".
- \<minute>
- : A 2-digit minute number. Examples: "04", "59".
- \<second>
- : A 2-digit second number. Examples: "04", "59".
- `GMT`
- `<day-name>`
- : One of "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", or "Sun" (case-sensitive).
- `<day>`
- : 2 digit day number, e.g., "04" or "23".
- `<month>`
- : One of "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" (case-sensitive).
- `<year>`
- : 4 digit year number, e.g. "1990" or "2016".
- `<hour>`
- : 2 digit hour number, e.g. "09" or "23".
- `<minute>`
- : 2 digit minute number, e.g. "04" or "59".
- `<second>`
- : 2 digit second number, e.g. "04" or "59".
- GMT
- : Greenwich Mean Time. HTTP dates are always expressed in GMT, never in local time.

## Examples
Expand All @@ -74,9 +70,8 @@ If-Unmodified-Since: Wed, 21 Oct 2015 07:28:00 GMT

## See also

- [HTTP Conditional Requests](/en-US/docs/Web/HTTP/Conditional_requests) guide
- {{HTTPHeader("Last-Modified")}}
- {{HTTPHeader("If-Modified-Since")}}
- {{HTTPHeader("If-Match")}}
- {{HTTPHeader("If-None-Match")}}
- {{HTTPHeader("Range")}}
- {{HTTPStatus("412", "412 Precondition Failed")}}
- {{HTTPHeader("If-Range")}}, {{HTTPHeader("Range")}} range request headers
- {{HTTPHeader("If-Match")}}, {{HTTPHeader("If-Modified-Since")}}, {{HTTPHeader("If-None-Match")}} conditional request headers
- {{HTTPStatus("304", "304 Not Modified")}}, {{HTTPStatus("412", "412 Precondition Failed")}} response status codes
39 changes: 18 additions & 21 deletions files/en-us/web/http/headers/last-modified/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ browser-compat: http.headers.Last-Modified

{{HTTPSidebar}}

The **`Last-Modified`** response HTTP header contains a date
and time when the origin server believes the resource was last modified. It is used
as a validator to determine if the resource is the same as the previously stored one. Less accurate
than an {{HTTPHeader("ETag")}} header, it is a fallback mechanism. Conditional requests
containing {{HTTPHeader("If-Modified-Since")}} or {{HTTPHeader("If-Unmodified-Since")}}
headers make use of this field.
The HTTP **`Last-Modified`** response header contains a date and time when the origin server believes the resource was last modified.
It is used as a validator in [conditional requests](/en-US/docs/Web/HTTP/Conditional_requests) ({{HTTPHeader("If-Modified-Since")}} or {{HTTPHeader("If-Unmodified-Since")}}) to determine if a requested resource is the same as one already stored by the client.
It is less accurate than an {{HTTPHeader("ETag")}} for determining file contents, but can be used as a fallback mechanism if ETags are unavailable.

`Last-Modified` is also used by [crawlers](/en-US/docs/Glossary/Crawler) to adjust crawl frequency, by browsers in [heuristic caching](/en-US/docs/Web/HTTP/Caching#heuristic_caching), and by content management systems (CMS) to display the time the content was last modified.

Expand All @@ -24,13 +21,13 @@ headers make use of this field.
</tr>
<tr>
<th scope="row">{{Glossary("Forbidden header name")}}</th>
<td>no</td>
<td>No</td>
</tr>
<tr>
<th scope="row">
{{Glossary("CORS-safelisted response header")}}
</th>
<td>yes</td>
<td>Yes</td>
</tr>
</tbody>
</table>
Expand All @@ -43,22 +40,21 @@ Last-Modified: <day-name>, <day> <month> <year> <hour>:<minute>:<second> GMT

## Directives

- \<day-name>
- `<day-name>`
- : One of "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", or "Sun" (case-sensitive).
- \<day>
- : 2 digit day number, e.g. "04" or "23".
- \<month>
- : One of "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov",
"Dec" (case sensitive).
- \<year>
- `<day>`
- : 2 digit day number, e.g., "04" or "23".
- `<month>`
- : One of "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" (case-sensitive).
- `<year>`
- : 4 digit year number, e.g. "1990" or "2016".
- \<hour>
- `<hour>`
- : 2 digit hour number, e.g. "09" or "23".
- \<minute>
- `<minute>`
- : 2 digit minute number, e.g. "04" or "59".
- \<second>
- `<second>`
- : 2 digit second number, e.g. "04" or "59".
- `GMT`
- GMT
- : Greenwich Mean Time. HTTP dates are always expressed in GMT, never in local time.

## Examples
Expand All @@ -77,6 +73,7 @@ Last-Modified: Wed, 21 Oct 2015 07:28:00 GMT

## See also

- {{HTTPHeader("If-Modified-Since")}}
- {{HTTPHeader("If-Unmodified-Since")}}
- {{HTTPHeader("Etag")}}
- [HTTP Conditional Requests](/en-US/docs/Web/HTTP/Conditional_requests) guide
- {{HTTPHeader("If-Match")}}, {{HTTPHeader("If-Modified-Since")}}, {{HTTPHeader("If-Unmodified-Since")}}, {{HTTPHeader("If-None-Match")}} conditional request headers
- {{HTTPStatus("304", "304 Not Modified")}}, {{HTTPStatus("412", "412 Precondition Failed")}} response status codes
45 changes: 41 additions & 4 deletions files/en-us/web/http/headers/link/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,36 @@ browser-compat: http.headers.Link

{{HTTPSidebar}}

The HTTP **`Link`** [entity header](/en-US/docs/Glossary/Entity_header) field provides a means for serializing one or more links in HTTP headers. This header has the same semantics as the HTML {{HTMLElement("link")}} element. The benefit of using the `Link` header is that the browser can start preconnecting or preloading resources before the HTML itself is fetched and processed.
The HTTP **`Link`** [entity header](/en-US/docs/Glossary/Entity_header) field provides a means for serializing one or more links in HTTP headers.
This allows the server to point a client to another resource containing metadata about the requested resource.
This header has the same semantics as the HTML {{HTMLElement("link")}} element.
One benefit of using the `Link` header is that the browser can start preconnecting or preloading resources before the HTML itself is fetched and processed.

In practice, most [`rel` link types](/en-US/docs/Web/HTML/Attributes/rel) don't have an effect when used with the HTTP header. For example, the `icon` relation only works in HTML, and `stylesheet` does not work reliably across browsers (only in Firefox).
In practice, most [`rel` link types](/en-US/docs/Web/HTML/Attributes/rel) don't have an effect when used with the HTTP header.
bsmth marked this conversation as resolved.
Show resolved Hide resolved
For example, the `icon` relation only works in HTML, and `stylesheet` does not work reliably across browsers (only in Firefox).
The only relations that work reliably are [`preconnect`](/en-US/docs/Web/HTML/Attributes/rel/preconnect) and [`preload`](/en-US/docs/Web/HTML/Attributes/rel/preload), which can be combined with {{HTTPStatus(103, "103 Early Hints")}}.

<table class="properties">
<tbody>
<tr>
<th scope="row">Header type</th>
<td>
{{Glossary("Entity header")}}
</td>
</tr>
<tr>
<th scope="row">{{Glossary("Forbidden header name")}}</th>
<td>No</td>
</tr>
<tr>
<th scope="row">
{{Glossary("CORS-safelisted response header")}}
</th>
<td>No</td>
</tr>
</tbody>
</table>

## Syntax

```http
Expand All @@ -24,6 +49,7 @@ Link: <uri-reference>; param1=value1; param2="value2"
### Parameters

The link header contains parameters, which are separated with `;` and are equivalent to attributes of the {{HTMLElement("link")}} element.
Values can be both quoted or unquoted based on [field value component rules](https://www.rfc-editor.org/rfc/rfc7230.html#section-3.2.6), so `x=y` is equivalent to `x="y"`.

## Examples

Expand All @@ -41,7 +67,7 @@ Link: https://bad.example; rel="preconnect"

### Encoding URLs

The URI (absolute or relative) must encode char codes greater than 255:
The URI (absolute or relative) must {{Glossary("Percent-encoding", "percent-encode")}} character codes greater than 255:

```http example-good
Link: <https://example.com/%E8%8B%97%E6%9D%A1>; rel="preconnect"
Expand All @@ -59,6 +85,16 @@ You can specify multiple links separated by commas, for example:
Link: <https://one.example.com>; rel="preconnect", <https://two.example.com>; rel="preconnect", <https://three.example.com>; rel="preconnect"
```

### Pagination through links

The `Link` header can provide pagination information to a client, which is commonly used to access resources programmatically:

```http
Link: <https://api.example.com/issues?page=2>; rel="prev", <https://api.example.com/issues?page=4>; rel="next", <https://api.example.com/issues?page=10>; rel="last", <https://api.example.com/issues?page=1>; rel="first"
```

In this case, `rel="prev"` and `rel="next"` show link relations for previous and next pages, and there are `rel="last"` and `rel="first"` parameters providing first and last pages of search results.

### Controlling fetch priority

Even when using [`preload`](/en-US/docs/Web/HTML/Attributes/rel/preload) to fetch a resource as early as possible, different types of content will be fetched earlier or later based on the browser's internal prioritization.
Expand All @@ -83,6 +119,7 @@ The `fetchpriority` directive should be used sparingly, and only in cases where

## See also

- {{HTTPStatus(103, "103 Early Hints")}}
- {{HTTPStatus("103", "103 Early Hints")}}
- {{HTMLElement("link")}}
- [Link Relations](https://www.iana.org/assignments/link-relations/link-relations.xhtml) IANA registry
- [Optimize resource loading with the Fetch Priority API](https://web.dev/articles/fetch-priority?hl=en#browser_priority_and_fetchpriority) for information about how this API affects priorities on Chrome.
42 changes: 14 additions & 28 deletions files/en-us/web/http/headers/location/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,22 @@ browser-compat: http.headers.Location

{{HTTPSidebar}}

The **`Location`** response header indicates the URL to
redirect a page to. It only provides a meaning when served with a
`3xx` (redirection) or `201` (created) status response.
The HTTP **`Location`** response header indicates the URL to redirect a page to.
It only provides a meaning when served with a `3XX` [redirection response](/en-US/docs/Web/HTTP/Status#redirection_messages) or a {{HTTPStatus("201", "201 Created")}} status response.

In cases of redirection, the HTTP method used to make the new request to fetch the page
pointed to by `Location` depends on the original method and the kind of
redirection:
In redirections, the HTTP method used to make the redirected request to fetch the page pointed to by `Location` depends on the original method and the kind of redirection:

- {{HTTPStatus("303")}} (See Other) responses always lead to the use of a
{{HTTPMethod("GET")}} method.
- {{HTTPStatus("307")}} (Temporary Redirect) and
{{HTTPStatus("308")}} (Permanent Redirect) don't change the method used in the
original request.
- {{HTTPStatus("301")}} (Moved Permanently) and {{HTTPStatus("302")}} (Found) don't
change the method most of the time, though older user-agents may (so you basically
don't know).
- {{HTTPStatus("303", "303 See Other")}} responses always result in a {{HTTPMethod("GET")}} request in the redirection.
- {{HTTPStatus("307", "307 Temporary Redirect")}} and {{HTTPStatus("308", "308 Permanent Redirect")}} use the same method as the initiating request.
- {{HTTPStatus("301", "301 Moved Permanently")}} and {{HTTPStatus("302", "302 Found")}} should use the same request method as the initiating request, although this is not guaranteed for older user-agents.

All responses with one of these status codes send a `Location` header.
All responses with one of the above status codes include a `Location` header.

In cases of resource creation, it indicates the URL to the newly created resource.
In cases of resource creation, it indicates the URL of the newly-created resource so that a client can make a request for it immediately.

`Location` and {{HTTPHeader("Content-Location")}} are different.
`Location` indicates the target of a redirection or the URL of a newly
created resource. {{HTTPHeader("Content-Location")}} indicates the direct URL to
use to access the resource when [content negotiation](/en-US/docs/Web/HTTP/Content_negotiation) happened,
without the need of further content negotiation. `Location` is a header
associated with the response, while {{HTTPHeader("Content-Location")}} is associated
with the entity returned.
`Content-Location` indicates the URL to use to directly access the resource in future when [content negotiation](/en-US/docs/Web/HTTP/Content_negotiation) occurred.
`Location` is associated with the response, while {{HTTPHeader("Content-Location")}} is associated with the representation that was returned.

<table class="properties">
<tbody>
Expand All @@ -44,7 +32,7 @@ with the entity returned.
</tr>
<tr>
<th scope="row">{{Glossary("Forbidden header name")}}</th>
<td>no</td>
<td>No</td>
</tr>
</tbody>
</table>
Expand All @@ -57,8 +45,8 @@ Location: <url>

## Directives

- \<url>
- : A relative (to the request URL) or absolute URL.
- `<url>`
- : May be relative to the request URL or an absolute URL.

## Examples

Expand All @@ -77,6 +65,4 @@ Location: /index.html
## See also

- {{HTTPHeader("Content-Location")}}
- Status of responses including a `Location` header: {{HTTPStatus("201")}},
{{HTTPStatus("301")}}, {{HTTPStatus("302")}}, {{HTTPStatus("303")}},
{{HTTPStatus("307")}}, {{HTTPStatus("308")}}.
- Status responses including a `Location` header: {{HTTPStatus("201")}}, {{HTTPStatus("301")}}, {{HTTPStatus("302")}}, {{HTTPStatus("303")}}, {{HTTPStatus("307")}}, {{HTTPStatus("308")}}.
11 changes: 8 additions & 3 deletions files/en-us/web/http/headers/max-forwards/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ spec-urls: https://httpwg.org/specs/rfc9110.html#field.max-forwards

{{HTTPSidebar}}

The **`Max-Forwards`** request HTTP header is used with the [`TRACE`](/en-US/docs/Web/HTTP/Methods/TRACE) method to limit the number of nodes (usually proxies) that request goes through. Its value is an integer value indicating the _maximum amount_ of nodes it must visit. At each node, the value is decremented and the `TRACE` request is forwarded to the next node, until the destination is reached, or the received value of `Max-Forwards` is zero. The request is then sent back, except for some headers, as the body of a `200 OK` response.
The HTTP **`Max-Forwards`** request header is used with the {{HTTPMethod("TRACE")}} method to limit the number of nodes (usually {{Glossary("Proxy_server", "proxies")}}) that the request goes through.
Its value is an integer indicating the _maximum amount_ of nodes it must visit.
At each node, the value is decremented and the `TRACE` request is forwarded to the next node until the destination is reached or the received value of `Max-Forwards` is zero.
The request is then sent back (excluding sensitive headers where appropriate) as the body of a {{HTTPStatus("200")}} response.
This allows the client to see what is being received at the other end of the request chain (the {{HTTPHeader("Via")}} header is of particular interest) for testing or diagnostic purposes.

If the `Max-Forwards` header is not present in a `TRACE` request, a node will assume that there is no maximum number of forwards.

Expand All @@ -19,7 +23,7 @@ If the `Max-Forwards` header is not present in a `TRACE` request, a node will as
</tr>
<tr>
<th scope="row">{{Glossary("Forbidden header name")}}</th>
<td>no</td>
<td>No</td>
</tr>
</tbody>
</table>
Expand Down Expand Up @@ -47,4 +51,5 @@ This feature is neither targeted at, nor implemented in, browsers.

## See also

- The HTTP [`TRACE`](/en-US/docs/Web/HTTP/Methods/TRACE) method
- {{HTTPMethod("TRACE")}} method
- {{HTTPStatus("405", "405 Method Not Allowed")}}
2 changes: 1 addition & 1 deletion files/en-us/web/http/headers/nel/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The HTTP **`NEL`** response header is used to configure network request logging.
</tr>
<tr>
<th scope="row">{{Glossary("Forbidden header name")}}</th>
<td>no</td>
<td>No</td>
</tr>
</tbody>
</table>
Expand Down
Loading
Loading