Headers: Content-Length
Content-Length header
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The HTTP Content-Length header indicates the size, in bytes, of the message body sent to the recipient.
Content-Length is limited in that the message size must be known up front, before sending the headers, which is a problem when content is dynamically generated or streamed.
- In HTTP/1.0, it is required.
- In HTTP/1.1, it could be replaced with
Transfer-Encoding: chunkedfor responses sent out in parts as its size is calculated. - In HTTP/2,
Content-Lengthis redundant, because the content length may be inferred from DATA frames. It may still be included for backwards compatibility.
| Header type | Request header, Response header, Content header |
|---|---|
| Forbidden request header | Yes |
| CORS-safelisted response header | Yes |
Syntax
Content-Length: <length>
Directives
<length>-
The length in octets.
Specifications
| Specification |
|---|
| HTTP Semantics> # field.content-length> |
Browser compatibility
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
Content-Length |
1 | 12 | 1 | 15 | 1 | 18 | 4 | 14 | 1 | 1.0 | 4.4 | 1 |
cors_response_safelist |
76 | 79 | 87 | 63 | 12.1 | 76 | 87 | 54 | 12.2 | 12.0 | 76 | 12.2 |
See also
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Length