【发布时间】:2016-02-13 00:58:36
【问题描述】:
向连接速度
我的 Express.js 应用程序确定要发送哪个文件并使用 response#download 方法进行响应:
app.get('/download-the-big-file', function(request, response) {
var file = {
name: 'awesome.file',
path: '/files/123-awesome.file'
};
response.header("X-Accel-Redirect: " + file.path);
response.download(file.path, file.name);
});
请注意,我将 X-Accel-Redirect 标头设置为利用 NginxXsendfile
我的 Nginx 配置:
server {
client_max_body_size 2g;
server_name localhost;
location / {
proxy_pass http://127.0.0.1:8000/;
}
location /files {
root /media/storage;
internal;
}
}
【问题讨论】: