This is my code for file download:
set_time_limit(0);
header('Set-Cookie: fileDownload=true; path=/'); //used for the file download library for the browser client https://github.com/johnculviner/jquery.fileDownload . Remove if the library isn't used anymore
header('Content-disposition: attachment; filename="' . $file->getName() . '"');
header('Content-Type: application/octet-stream');
header("Pragma: public");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
while (!feof($stream)) {
echo fread($stream, 8192);
ob_flush();
flush();
}
The problem is that when i open the url for the file and the file has size bigger than 100MB for example, there is a huge delay for the download to actually start. Can someone explain to me what's causing it and how can be fixed? EDIT: The problem is solved. It turned out that my web server had an output buffering turned on by default.