Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

Downloads stopping after 5 min thinking they are done


Recommended Posts



If anyone else is having trouble with a MS IIs system stopping downloads after 5 minutes I know now what the problem is. The CGI timout function in the MS server defaults to 300 seconds. which pretty much screws you for large downloads on a slow connection. The amount of time it takes for the download window to popup is also included in the 300 seconds.


My server's download speed to my system is 44kps and I can only get 10.4 mb of a large file with the download.php file in it's default configuration. I also noticed about 1 minute pause from the time I click the download link till the time I actually got the download window popup. By making the changes below I was able to get instant popup of the download dialog and increase the amount of the file I can actually download to 12.6 mb.


My hosting company is rather stingy in increasing my CGI timeout time, I requested a specific amout. I'll probably be transfering my domain later this week. Rather than increase the time by enough to complete a download they suggested that I ask all my customers to get download managers that would allow them to resume incomplete downloads. Hell I can add a line or two of code and do this without bother everyone that decides to do business with me to get a download manager. I'd like to have a seamless download at a reasonable speed without my having to babysit it 24/7.


Am I being unreasonable? Anyway here is the code I added to speed up the download somewhat, on my server it increases performance by 30%. So it will increase the size of a download for some folks anyway.


Here is the code:


at the bottom of the download.php there is a if then else statement replace the else part of the code with this segment:


else {

// This will work on all systems, but will need considerable resources

// We could also loop with fread($fp, 4096) to save memory

// readfile(DIR_FS_DOWNLOAD . $downloads['orders_products_filename']);

// this is the new code below. the old code is above this line. if you need to go back just remove the slashes and delete the lines below.

if ($file = fopen(DIR_FS_DOWNLOAD . $downloads['orders_products_filename'], 'rb')) {

while(!feof($file) and (connection_status()==0)) {


echo(fread($file, 1024*4096));




} }

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...