简体   繁体   English

Apache和PHP下载超时

[英]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. 目前,当客户购买播客时,会向他/她显示直接的HTML链接以开始下载。 The link points to a ZIP file which can be 1Gb in size. 该链接指向一个ZIP文件,该文件的大小可以为1Gb。 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? 我要问的一个问题是,当Apache服务器可能有几分钟的超时时间时,为什么下载可以成功运行几个小时? 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. 我认为此超时是针对服务器处理GET请求并将结果输出通过输出缓冲区发送到浏览器的。 Perhaps there is no timeout for the buffer to be transmitted to the user. 也许没有超时时间可以将缓冲区发送给用户。 Am I correct? 我对么?

My second question is about PHP timeouts. 我的第二个问题是关于PHP超时。 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. 我不喜欢指向下载的HTML直接链接,就像其他用户可以免费下载该URL一样。 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. 一种解决方案是使用PHP脚本来发送下载文件,方法是发送适当的标头,然后发送预加载了下载数据的变量的“回显”。 My question is whether the timeouts in the php.ini file would effect the download. 我的问题是php.ini文件中的超时是否会影响下载。 These are usually 30 secs for the script to complete. 通常需要30秒才能完成脚本。 So, is the script running during the download? 那么,脚本在下载过程中运行吗? Alternatively does the script complete quickly and put the download data into a PHP output buffer. 或者,脚本是否可以快速完成并将下载数据放入PHP输出缓冲区。 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. 我想我必须为php.ini中的'memory_limit'设置一个较大的值(默认为128Mb),以允许1Gb下载的大小。

Try setting a much larger stream timeout PHP STREAM TIMEOUT . 尝试设置更大的流超时PHP STREAM TIMEOUT You can use phpinfo to see what the default value is. 您可以使用phpinfo查看默认值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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