Images not loading, network :: ERR_CONTENT_LENGTH_MISMATCH

Problem

When loading a page on my site, one (or several) images (jpg files that I saved from Lightroom and / or Photoshop) often do not appear. Instead, it looks like a broken link (an ALT description appears), but there is no image. A hard reload of the browser solves the problem (for example, all images load properly after a hard reload).

Error message

Chrome displays an “ERR_CONTENT_LENGTH_MISMATCH” warning for all images that it does not upload. (Sometimes the image blinks quickly before moving on to what looks like a dead image)

Customization

Running the latest version of Wordpress (4.2.2) on a shared host. The site is SSL (https), if that matters. Images are located in the image upload folder (nothing complicated like Imagemagick, etc.) on the host.

Troubleshooting

I replicated the problem from several places using different Internet providers on different computers (both Mac and PC) and with different browsers (Chrome and Safari), some of which do not use ad units.

I tried the following:

  • I asked the host if there was a problem on the server side. They say no.
  • I tried to reset the functions.php file. Does not affect.
  • I disabled all plugins. Does not affect.
  • In meta-encoding, I was configured as UTF-8. Does not affect.
  • Checked if I use Gzip. I do not.
  • The Wordpress Cache plugin is included. Does not affect.
  • Cleared the .htaccess of all optional redirects and commands. no impact.
  • Replaced wp-admin and wp-includes folders from the new installation. no impact.
  • Removed Wordpress and reinstalled from backup. No dice.
  • I put the source code from pages that have this problem into the test.html file and the images seem to load very well.

My thoughts and questions

Images are 100-200 kb each, and sometimes their number on the page is quite a lot. Is there a timeout, and then when I recharge a lot, everything appears because the timeout did not work? This is the best random guess I can put together without understanding the problem perfectly.

Any ideas I can try? Should I delete the entire database and start over? Everything I know about computers is self-taught, and server problems are not a strong point for me. Even if you don’t know what it could be, can someone explain that the content length mismatch is broad?

Thanks a lot!

+5
source share
3 answers

When you request data from a web server, first some information about the data (HTTP headers) is answered, and then the data. One of these pieces of information, the HTTP header, is called Content-Length . It tells the client how much data it should expect from the server. When your browser receives the image, the server response (looks very simplified)

 Content-Length: 100000 < the image, 100000 bytes of data > 

The client knows that the request completed when it received the amount of data specified by the Content-Length . Until he receives in this case 100 KB (100,000 bytes), he believes that the image, for example, should not be executed when downloading.

If the server interrupts the request before the client receives data from the server, or if the client receives more data than it received, the client will throw some kind of error and assume that the data will be damaged / unusable and disposed of. This. How this is handled may vary between browsers.

How did you upload images to your site? I myself ran into this problem in a situation where the file size was supposedly saved in the database, and this was used to set the Content-Length header. The file size in the database was incorrect for the file. HOWEVER, I know that WordPress does n’t do the size of the storage in the database; Media downloads are simply represented by a URL.

This can also happen if the web server has run out of resources and can no longer fulfill your requests; You said that you have many images on the page. If you are actually a lousy shared hosting plan, it may be that the host imposes restrictions or that the server simply cannot handle the traffic of all the sites that it hosts.

+4
source

I wanted to come back to this if someone else ran into this problem. There seems to be some type of failure between HTTPS and image extraction, which caused the problem. Although I don’t understand WHY what it is, I converted my site from SSL / HTTPS to plain HTTP (which I was able to do since it does not require encryption) and it seems that all the images load the way they should.

If someone understands the why, I would like to understand what the problem really is. Fortunately, I was able to come up with a workaround. Thus, although this does not answer my question, it provides the context of what is causing the problem, and a workaround for my common sense.

0
source

You may have a problem with shared hosting. Free bandwidth is free speech, not free beer. Reset policies are triggered during traffic spikes.

The distributed system architecture solves this by inserting an entry-level CDN (e.g. CloudFlare). CDNs caches your static resources and can significantly reduce the load on your host. In fact, for fully static sites, the host can be down.

There are other benefits to CDN, such as attack detection, free SSL (no beer), and overall improved performance and security over shared hosting.

Many CDNs are free (as in speech). You can also switch to private hosting, but $ and you might want to use the interface level.

0
source

All Articles