When you do a XMLHttpRequest, the data is often compressed. Looking at the Content-Length
header
xhr.getResponseHeader("Content-Length");
gives you the number of octets in the response body, to which you could add an approximation of the header by sizing the response headers.
But: How do you find the number of (compressed) bytes actually transferred? (in Firefox, if this is only possible in a browser-specific way.)
In the screenshot below, you see a difference for several files:
The following should all be equal to this
- the number of bytes read from the socket
- the file size in the squid log
- the number of application-layer octets sent over the network in response to the request