JavaEar 专注于收集分享传播有价值的技术资料

Failed to load resource: net::ERR_CONTENT_LENGTH_MISMATCH

What does this error message mean and how do I resolve it? That is from console of Google Chrome v33.0, on Windows 7.

Failed to load resource: net::ERR_CONTENT_LENGTH_MISMATCH           http://and.img.url/here.png

I'm trying to change the images' src attribute using jQuery. For example like this (simplified):

$('.image-prld').attr('src', someDynamicValue);

There are about 30 images on the page. And the above error is happening for random images every time when I reload the page. But sometimes it is working well for all the images, without any error.

When this error happens, the particular image is displaying like this:

enter image description here

However, when I open the link next to the error message on a new tab, the image is loading, which says me logically that the images is valid and it exists.

6个回答

    最佳答案
  1. This error is definite mismatch between the data that is advertised in the HTTP Headers and the data transferred over the wire.

    It could come from the following:

    1. Server: If a server has a bug with certain modules that changes the content but don't update the content-length in the header or just doesn't work properly. It was the case for the Node HTTP Proxy at some point (see here)

    2. Proxy: Any proxy between you and your server could be modifying the request and not update the content-length header.

    As far as I know, I haven't see those problem in IIS but mostly with custom written code.

    Let me know if that helps.

  2. 参考答案2
  3. It could be even caused by your ad blocker.

    Try to disable it or adding an exception for the domain from which the images come from.

  4. 参考答案3
  5. In my situation, the problem was nginx's disk space. I had 10GB of logs and when I reduce this amount it works.

    Step by step: I have a docker container with nginx.

    1. Enter in your container: docker exec -it container_id bash.

    2. Go to your logs, for example: /var/log/nginx .

    3. Show file size: ls -lh for individual file size or du -h for folder size.

    4. Empty file/s with echo "" > file_name.

    5. It works!.

    Problem ERR_CONTENT_LENGTH_MISMATCH?

  6. 参考答案4
  7. In my case I was modifying the request to append a header (using Fiddler) to an https request, but I did not configure it to decrypt https traffic.

  8. 参考答案5
  9. In my case I was miscalculating the Content-Length that I advertised in the header. I was serving Range-Requests for files and I mistakenly published the filesize in Content-Length.

    I fixed the problem by setting Content-Length to the actual range that I was sending back to the browser.

    So in case I am answering to a normal request I set the Content-Length to the filesize. In case I am answering to a range-request I set the Content-Length to the actualy length of the requested range.

  10. 参考答案6
  11. I have been suffering from this issue for a month, in my case this problem came from AdBlock, so I disable it and all work very well.

    I hope this can help someone