Contains the size, in bytes, of the body of the response.
The Content-Length header tells the client how long the body of the response is going to be, in bytes. Because of compression, the actual length of the decompressed content may differ from the length of the document that was sent. This header indicates the length of the compressed content. The actual number of bytes sent over the wire.
This information is important for the client to know, so it can display a progress bar of the download, for example. It also allows the web browser to know when the response has finished, so that it can close the connection to the server (in the case where the server does not close it).
As an alternative, a server using HTTP/1.1 could set the Transfer-Encoding header instead with a value of
chunked which indicates that the server will be sending the response in a series of chunks that are sent down the same connection one after the other. This approach is useful in the case where the size of the document is unknown or if additional headers need to be set after some of the content has been sent.
Ready to validate your website to check for this header and 100+ others important tests?