Intermittent failure to load images - ERR_CONTENT_LENGTH_MISMATCH Intermittent failure to load images - ERR_CONTENT_LENGTH_MISMATCH php php

Intermittent failure to load images - ERR_CONTENT_LENGTH_MISMATCH


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.
  2. Proxy : Any proxy between you and your server could be modifying the request and not update the content-length header.

This could also happens if setting wrong content-type.

As far as I know, I haven't see those problem in IIS/apache/tomcat but mostly with custom written code. (Writing image yourself on the response stream)

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.


Suggest accessing the image as a discrete url using cURL, egphp testCurlimg >image.log 2>&1 to see exactly what is being returned by the server. Then you can move upon level to test the webpagephp testCurlpg >page.log 2>&1 to see the context for mixed data


I just ran into this same ERR_CONTENT_LENGTH_MISMATCH error. I optimized the image and that fixed it. I did the image optimization using ImageOptim but I'm guessing that any image optimization tool would work.