Problem
Shared file downloads are always streamed through PHP (FileResponse::send() -> fopen + chunked echo). This holds a PHP worker open for the entire download, has no range-resume support, and is inefficient for large files. This is especially bad when mutliple files are sent at the same time and they are blocking other requests because of it.
When running behind a proxy, it would be better to hand file delivery off to the web server when possible. For example the Apache server has the ability to send a file when receiving the X-Sendfile-header.
I do not want remove the existing PHP streaming code. It is useful (built-in server, Nginx-less setups, environments without mod_xsendfile) and must remain the default/fallback.
Changes
- Add
KITTYSHARE_FILE_DELIVERY=php|x-sendfile (default: php).
- Parse it in
ConfigManager, store as a typed field on Config
- In
FileResponse, when mode is x-sendfile: send Content-Type, Content-Length, and the existing X-Content-Type-Options / Content-Security-Policy headers plus X-Sendfile: <absolute path>, with no response body.
Problem
Shared file downloads are always streamed through PHP (
FileResponse::send()->fopen+ chunked echo). This holds a PHP worker open for the entire download, has no range-resume support, and is inefficient for large files. This is especially bad when mutliple files are sent at the same time and they are blocking other requests because of it.When running behind a proxy, it would be better to hand file delivery off to the web server when possible. For example the Apache server has the ability to send a file when receiving the
X-Sendfile-header.I do not want remove the existing PHP streaming code. It is useful (built-in server, Nginx-less setups, environments without
mod_xsendfile) and must remain the default/fallback.Changes
KITTYSHARE_FILE_DELIVERY=php|x-sendfile(default: php).ConfigManager, store as a typed field onConfigFileResponse, when mode isx-sendfile: sendContent-Type,Content-Length, and the existingX-Content-Type-Options/Content-Security-Policyheaders plusX-Sendfile: <absolute path>, with no response body.