What's The Deal With X-SendFile? What's The Deal With X-SendFile? curl curl

What's The Deal With X-SendFile?


It allows the webserver to send the file in whatever it thinks is the best way to send that file to the client. It also enables support for range requests (i.e. download managers and resuming) as long as the webserver supports it without writing a single line of code for it.

However, "typical low-budged shared web hosts" are unlikely to support it. Consider if you really want to target them though; that usually also involves supporting outdated PHP versions, nasty configurations (safe_mode and/or magic_quotes enabled) and lack of PHP modules such as PDO (always enabled in recent PHP versions, but see one of my previous points).

Any other way of sending files to the client has the disadvantage that PHP needs to read it and then pass it to the webserver as string data (which is not efficient compared to e.g. letting the kernel write a whole file to a socket). When using file_get_contents it is even worse - you read the whole file into memory which is not necessary at all.