phpapachesymfonyfirefoxsymfony-http-foundation

BinaryFileResponse not working correctly in Firefox - Image corrupt or truncated


I'm facing some weird issues when Firefox tries to load PHP generated image files. Occurs on Mac and Windows (7, 8, 10).

The Firefox console says:

Image corrupt or truncated.

Everything works fine in Chrome, Safari and IE/Edge.

But it's not an constant error, sometimes the same images load fully or at least partially in Firefox.

Static images served directly by Apache are also working without any problems.

The server-side code is pretty basic and looks as follows:

$response = new BinaryFileResponse($file->getPathname());

return $response;

Here is the raw response header of the static (working) images:

Connection: close
Date: Thu, 20 Oct 2016 11:55:04 GMT
Etag: "1ab1567-d2e0-53f396a39fd2e"
Server: Apache
Vary: User-Agent

Here the one of the PHP generated images:

Accept-Ranges: bytes
Cache-Control: max-age=1209600, public, s-maxage=1209600
Connection: close
Content-Encoding: gzip
Content-Type: image/jpeg
Date: Thu, 20 Oct 2016 11:57:45 GMT
Last-Modified: Thu, 20 Oct 2016 10:12:05 GMT
Server: Apache
Transfer-Encoding: chunked
Vary: Accept-Encoding,User-Agent

One thing to mention, I use the same script in about 30 websites without any issues. So maybe this is a server-side problem?


Solution

  • In my case the reason was the installed AdBlock Plus Plugin in Firefox ;)