On 12/21/06, <b class="gmail_sendername">Ezra Zygmuntowicz</b> <<a href="mailto:ezmobius@gmail.com">ezmobius@gmail.com</a>> wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
The rails send_file method is not the same thing as setting an X-<br>SendFile header. If you are already using lighttpd for your server<br>then your in good shape. THe rails send_file method actually does<br>read the whole file into memory as it sends it to the client. SO you
<br>will see memory problems like you have if you use it on large files.<br>The nice way to do it is to use the X-SendFile header in lighty. In a<br>rails action that just wants to serve a static file from somewhere<br>off the filesystem you can make it look like this:
</blockquote><div><br>To be clear, send_file does not read the whole file into memory -- it blows chunks into the output stream. Mongrel and pure-Ruby FastCGI use StringIO to buffer the response before sending it to the client.
<br><br>X-Sendfile is definitely the way to go in any case.<br><br>jeremy</div></div>