Closed EngRajabi closed 7 years ago
in many projects , there are some send file that are needed to set speed send file
bute im used to \Yii::$app->response->sendFile()->send(); not used popular nginx
can't the nginx limit be combined with sendFile() ? Not sure if/how Yii could control download speed...
Maybe http://stackoverflow.com/questions/4002106/limit-download-speed-using-php ? Doesn't sound as a bad idea if you can control the timeout of each PHP process. And if not, Yii could ignore the speed limit (or throw a warning/error)
It should be implemented on the web-server's side IMO.
@usualdesigner Yii is on the server side. Anyways, I get what you mean: the web server should take care about that. There is a problem with that: you can't programaticaly control how the webserver sends the file.
sleep(1);
it's not true for highload
@lynicidn ???
@samdark script work up time
set_time_limit(0) - not true :)
Can't get what you're trying to say. Sorry.
@samdark тот путь что черех пхп, он работает через sleep, что приостонавливает работу скрипта, т.е. пхп занят, а скрипт в паузе, да и вообще set time limit это не настройка для отдачи файлов пачками, это костыль для этого
А, ну это понятно.
I don't think this should be in the core.
Extensions could be created that support a specific sending backend (nginx, apache, PHP) and implement the limit there.
Note that implementing this in PHP could be a bad idea because the webserver tends to buffer the response which could cause weird results like getting lower throughput. For example if the webserver buffers 10 seconds of ratelimited output and then sends that to the client at once, who cannot handle that data fast enough, then the effective download speed will be much lower than intended.
Agree.
send file \Yii::$app->response->sendFile('path/to/file.txt')->send(); bute send file with speed \Yii::$app->response->sendFile('path/to/file.txt',900)->send(); add property set speed