Free auditStart free
GlossaryGlossary · HTTP

Content-Length (HTTP header)

The HTTP Content-Length header gives the size of the message body in bytes. See when to send it, when not to, what a 411 means, and how to check yours.

3 min
read
3
sources
Oct 21, 2026
updated
Scaplet Editorial Team
author
In one line

The HTTP Content-Length header indicates the size, in bytes, of the message body sent to the recipient. MDN says the message size must be known up front, before the headers are sent, which is a problem for dynamically generated or streamed content. HTTP/1.1 can use Transfer-Encoding: chunked instead, and in HTTP/2 the header is redundant.

30-second check

Is this costing your site traffic?

Four quick questions, then a straight answer.

1/4Have you checked your own site for this?
Summarize this page withChatGPTClaudePerplexityGoogleAI Mode
01Explained

What the header does

Content-Length tells the receiver how many bytes of message body to expect. RFC 9110 defines it as the representation's data length as a decimal non-negative integer number of octets, for example Content-Length: 3495. It lets recipients delimit the message, measure transfer progress, know when a received message is complete, and potentially reuse the connection for more requests.

It appears in requests (POST bodies) and responses. The same RFC says a client normally sends it on a POST request even when the value is 0, indicating empty content.

03Worth knowing

Chunked, HTTP/2 and compression

Streamed or generated responses

In HTTP/1.1, Transfer-Encoding: chunked can replace Content-Length for responses sent in parts as their size is calculated, per MDN.

HTTP/2

MDN says Content-Length is redundant because the length can be inferred from DATA frames, though it may still be included for backwards compatibility. See HTTP/2.

Wrong values

RFC 9110 says a sender must not forward a message with a value known to be incorrect. If something in your stack rewrites the body, such as compression, the value has to describe the body that is actually sent. See gzip compression.

04Explained

Errors tied to it

RFC 9110 defines the 411 Length Required status: the server refuses to accept the request without a defined Content-Length. The client may repeat the request if it adds a valid header containing the length of the request content. See 411 Length Required. For uploads the server rejects as too big, see 413 Content Too Large. Both belong to the wider family of HTTP status codes.

05Check it

Check it in 2 minutes

On a static, uncompressed file the two numbers should match. If they differ, something between you and the origin changed the body, or the server computed the length differently for HEAD. If Content-Length is missing and Transfer-Encoding: chunked is present, the response is sent in parts.

Read the length your server sends
curl -sI https://example.com/ | grep -i -E 'content-length|transfer-encoding|content-encoding'
curl -s https://example.com/ | wc -c
06Explained

Not the same as article length

People also search "content length" meaning word count. Google's helpful content guidance asks whether you're writing to a particular word count because you've heard that Google has a preferred word count, and answers: no, it doesn't. Length should follow what the reader needs.

Questions

Asked a lot.

5 questions people ask next, answered from the sources on this page.

01What is Content-Length in HTTP?

A header that indicates the size, in bytes, of the message body sent to the recipient. RFC 9110 defines it as a decimal non-negative integer number of octets.

02Is Content-Length required?

In HTTP/1.0 it is required, per MDN. In HTTP/1.1 it can be replaced with Transfer-Encoding: chunked for responses sent in parts, and in HTTP/2 it is redundant.

03What does a 411 Length Required error mean?

The server refuses to accept the request without a defined Content-Length. Add a valid header with the length of the request content and retry.

04Is there a maximum Content-Length?

RFC 9110 says there is no predefined limit to the length of content, so a recipient must anticipate potentially large numbers. Servers can still set their own limits and answer 413.

05Does Google have a preferred content length for articles?

No. Google's guidance says it does not have a preferred word count.

Sources · 3

Every fact, linked and dated.

Official docs first. The date is when we last opened each page.
  • mozilla.org
  • rfc-editor.org
  • google.com
  1. 01Content-Length header (MDN Web Docs)developer.mozilla.org · checked 2026-10-25
  2. 02RFC 9110: HTTP Semanticsrfc-editor.org · checked 2026-10-25
  3. 03Creating helpful, reliable, people-first content (Google Search Central)developers.google.com · checked 2026-10-25
Free · 2 minutes

Know the term. Now check your site.

The free audit reads robots.txt, sitemaps, status codes, canonicals, redirects and structured data.

Free, no card60 secondsNobody will call you
  • 46 fixes shipped without a ticket Brightpipe
  • +212% organic clicks in 90 days Ledgerly