views:

62

answers:

1

I have a 15MB file on a website (Apache webserver) that downloads fine on reasonable speed connections, but is almost always incomplete on slower connections (28KBytes/sec, for example). The size of the incomplete file is random, from 2 to 13 MB. I have verified the behavior in both Safari and Firefox, on a connection with negligible latency. Neither browser indicates to the user that the file is incomplete, but the size is smaller than 15MB. I have tried downloading via a direct link and via a PHP download script with the proper headers: same results.

Has anyone else experienced this kind of issue?

A: 

If you use your PHP script for sending the file you will run into PHPs script limit on large downloads. See php.ini for max_execution_time.

So you don't want to read your file with PHP and then echo it to the browser.

Instead you like to redirect the browser to the file.

JochenJung
As I indicated in my question, I have tried both PHP and direct links with similar results. The PHP script is running on Linux, which does not count file and network operations against max_execution_time.
Aaron
max_execution_time is a PHP setting, that has nothing to do with the underlying operating system. Because PHP has an output buffer, the script needs to wait until more data gets transfered. This is why max_execution_time matters when there is low bandwidth. But if you access the file without PHP and run into the same problem, then you're right and it has nothing to do with PHP or max_execution_time.
JochenJung
Actually, the counting of time IS operating system dependent (http://www.soliantconsulting.com/blog/2010/02/phps-max_execution_time-different-on-windows-and-linux/) Linux does not tally time spent in blocking requests (i.e. reading files and network transmissions) and Windows does.
Aaron
Oh, nice to know. Does the slow network connection in your case act like the sleep(30) as well? Cause I had the exact same situation when generating downloads via PHP. On slow connections the the download was incomplete (it was a linux server as well) and for me the solution was to increase max_execution_time
JochenJung