{"id":704,"date":"2009-02-10T11:24:59","date_gmt":"2009-02-10T02:24:59","guid":{"rendered":"http:\/\/ecpplus.net\/weblog\/?p=704"},"modified":"2020-06-15T22:09:31","modified_gmt":"2020-06-15T13:09:31","slug":"rails-lighttpd-big-file-download","status":"publish","type":"post","link":"https:\/\/ecpplus.net\/weblog\/rails-lighttpd-big-file-download\/","title":{"rendered":"Rails&#038;lighttpd\u3067\u5927\u5bb9\u91cf\u30d5\u30a1\u30a4\u30eb\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3055\u305b\u308b\u65b9\u6cd5"},"content":{"rendered":"<p>Rails\uff06Lighttpd\u306e\u74b0\u5883\u3067\u52d5\u753b\u3068\u304b\u5927\u5bb9\u91cf\u30d5\u30a1\u30a4\u30eb\u3092\u9ad8\u901f\u306b\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3055\u305b\u308b\u3068\u304d\u3001Rails \u306e send_file \u3092\u4f7f\u308f\u305a\u306b Lighttpd \u306e X-sendfile \u3068\u3044\u3046\u4ed5\u7d44\u307f\u3092\u4f7f\u3046\u3068\u826f\u3044\u3088\u3046\u3067\u3059\u3002<\/p>\n<p>lighttpd-1.4.15 \u3067\u8a66\u3057\u307e\u3057\u305f\u3002<\/p>\n<h3>\u901a\u5e38\u306esend_file<\/h3>\n<pre lang=\"ruby\">send_file '\/tmp\/movie.wmv'<\/pre>\n<h3>Lighttpd\u3092\u4f7f\u3063\u305fx-sendfile<\/h3>\n<pre lang=\"ruby\"># X_SENDFILE \u3059\u308b\npath = '\/tmp\/movie.wmv'\nresponse.headers['Content-Type'] = \"application\/force-download\"\nresponse.headers['Content-Disposition'] = \"attachment; filename=\\\"123.mmv\\\"\"  # \u597d\u304d\u306a\u540d\u524d\u3067\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3055\u305b\u308b\nresponse.headers[\"X-LIGHTTPD-SEND-FILE\"] = path\nresponse.headers['Content-length'] = File.size(path)\nrender :nothing => true<\/pre>\n<p>\u3053\u308c\u3060\u3051\u3067\u306f\u30c0\u30e1\u3067\u3001lighttpd\u306e\u8a2d\u5b9a\u3082\u5909\u66f4\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u3002<\/p>\n<p>lighttpd\u306b\u30d1\u30b9\u304c\u901a\u3063\u3066\u308b\u74b0\u5883\u3067\u306f lighttpd \u304c\u512a\u5148\u7684\u306b\u8d77\u52d5\u3055\u308c\u308b\u304c\u3001\u521d\u56de\u8d77\u52d5\u6642\u306b config\/lighttpd.conf \u304c\u751f\u6210\u3055\u308c\u308b\u306f\u305a\u3067\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u304f\u3060\u308a\u304c\u3042\u308b\u306f\u305a\u3002<\/p>\n<pre lang=\"\">fastcgi.server      = ( \".fcgi\" => ( \"localhost\" => (\n  \"min-procs\"       => 1,\n  \"max-procs\"       => 1,\n  \"socket\"          => CWD + \"\/tmp\/sockets\/fcgi.socket\",\n  \"bin-path\"        => CWD + \"\/public\/dispatch.fcgi\",\n  \"bin-environment\" => ( \"RAILS_ENV\" => \"development\" )\n) ) )<\/pre>\n<p>\u3053\u3053\u306b\u3001<code> \"allow-x-send-file\" => \"enable\"<\/code> \u3092\u8ffd\u52a0\u3059\u308b\u3068\u5148\u307b\u3069\u306e X-LIGHTTPD-SEND-FILE \u304c\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002\u8ffd\u52a0\u3057\u306a\u3044\u3068\u3001\u30a8\u30e9\u30fc\u306f\u8d77\u304d\u306a\u3044\u3051\u3069\u30011byte\u306e\u7a7a\u30d5\u30a1\u30a4\u30eb\u3057\u304b\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3055\u308c\u307e\u305b\u3093\u3002<\/p>\n<p>\u8a2d\u5b9a\u3059\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre lang=\"\">fastcgi.server      = ( \".fcgi\" => ( \"localhost\" => (\n  \"allow-x-send-file\" => \"enable\",\n  \"min-procs\"       => 1,\n  \"max-procs\"       => 1,\n  \"socket\"          => CWD + \"\/tmp\/sockets\/fcgi.socket\",\n  \"bin-path\"        => CWD + \"\/public\/dispatch.fcgi\",\n  \"bin-environment\" => ( \"RAILS_ENV\" => \"development\" )\n) ) )<\/pre>\n<p>x-send-file \u306e\u6ce8\u610f\u70b9\u3067\u306f\u306a\u3044\u3067\u3059\u304c\u3001IE\u3067\u306f \u30d8\u30c3\u30c0\u306b <code>Cache-Control: no-cache<\/code> \u304c\u3064\u3044\u3066\u3044\u305f\u5834\u5408\u3001SSL\u3067\u30d5\u30a1\u30a4\u30eb\u306e\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u304c\u51fa\u6765\u306a\u3044\u3068\u3044\u3046\u4ed5\u69d8\u304c\u3042\u308a\u307e\u3059\u3002\u3053\u3046\u3044\u3046\u3068\u304d\u306f\u3001SSL\u3092\u7d4c\u7531\u3057\u306a\u3044\u3088\u3046\u306b\u3059\u308b\u304b\u3001no-cache \u3092\u3084\u3081\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u3069\u3046\u3044\u3046\u4ed5\u69d8\u306a\u3093\u3060\u308d\u3046\u2026\u3002<\/p>\n<p>\u3069\u3046\u3044\u3046\u6761\u4ef6\u304b\u308f\u304b\u3089\u306a\u3044\u304c\u3001\u30d5\u30a1\u30a4\u30eb\u304c\u5909\u66f4\u3055\u308c\u3066\u3082304 Not Modified \u304c\u8fd4\u3055\u308c\u3066\u3057\u307e\u3046\u3053\u3068\u304c\u3042\u308b\u3053\u3068\u304c\u767a\u899a\u3002\u5f37\u5236\u7684\u306b\u3001200\u3092\u8fd4\u3057\u3066\u3042\u3052\u308c\u3070\u6700\u65b0\u306e\u30d5\u30a1\u30a4\u30eb\u304c\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3055\u308c\u307e\u3059\u3002\u9006\u306b\u5909\u66f4\u3055\u308c\u3066\u3044\u306a\u3044\u5834\u5408\u306f304\u3092\u8fd4\u3057\u305f\u3044\u306e\u3067\u3001\u305d\u3046\u3044\u3046\u5272\u308a\u5f53\u3066\u3092\u3059\u308c\u3070\u826f\u3044\u306e\u3060\u304c\u3002<\/p>\n<pre lang=\"ruby\">render :status => 200<\/pre>\n<p>\u3068\u304b\u3067\u3001\u5f37\u5236\u7684\u306b200\u3092\u8fd4\u305b\u308b\u3088\u3046\u3060\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Rails\uff06Lighttpd\u306e\u74b0\u5883\u3067\u52d5\u753b\u3068\u304b\u5927\u5bb9\u91cf\u30d5\u30a1\u30a4\u30eb\u3092\u9ad8\u901f\u306b\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3055\u305b\u308b\u3068\u304d\u3001Rails \u306e send_file \u3092\u4f7f\u308f\u305a\u306b Lighttpd \u306e X-sendfile \u3068\u3044\u3046\u4ed5\u7d44\u307f\u3092\u4f7f\u3046\u3068\u826f\u3044\u3088\u3046\u3067\u3059\u3002 l [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2521,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[7,10],"class_list":["post-704","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-development","tag-linux","tag-rails"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/posts\/704","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/comments?post=704"}],"version-history":[{"count":2,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/posts\/704\/revisions"}],"predecessor-version":[{"id":2539,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/posts\/704\/revisions\/2539"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/media\/2521"}],"wp:attachment":[{"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/media?parent=704"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/categories?post=704"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/tags?post=704"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}