简体   繁体   中英

Timeouts on Apache and PHP downloads

I run a website which sells audio downloads for doctors. At present when a customer buys a podcast he/she is shown a direct HTML link to start the download. The link points to a ZIP file which can be 1Gb in size. One question I ask is, why can the download operate successfully for perhaps some hours when the Apache server has a timeout of perhaps a few mins? I presume this timeout is for the server to process the GET request and to sent the resultant output to the browser via an output buffer. Perhaps there is no timeout for the buffer to be transmitted to the user. Am I correct?

My second question is about PHP timeouts. I'm not keen on an HTML direct link to a download as if the URL became known to other users they could download for free. A solution could be to use a PHP script to transfer the download file by sending the appropriate headers then, say, an 'echo' of a variable preloaded with the download data. My question is whether the timeouts in the php.ini file would effect the download. These are usually 30 secs for the script to complete. So, is the script running during the download? Alternatively does the script complete quickly and put the download data into a PHP output buffer. If the latter, is there any timeout for the buffer to empty?

I presume I'd have to set a large value for the 'memory_limit' in php.ini (128Mb by default) to allow for the size of the 1Gb download.

Try setting a much larger stream timeout PHP STREAM TIMEOUT . You can use phpinfo to see what the default value is.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM