# Byte-range requests

**URL:** <https://www.ruby-forum.com/t/byte-range-requests/119592>\
**Category:** Mongrel\
**Created:** [November 8, 2007, 7:44am UTC](https://www.ruby-forum.com/t/byte-range-requests/119592 "2007-11-08T07:44:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![equinox86](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/4af34b/32.png) [@equinox86](https://www.ruby-forum.com/u/equinox86)\
**Post date:** [November 8, 2007, 7:44am UTC](https://www.ruby-forum.com/t/byte-range-requests/119592/1 "2007-11-08T07:44:18Z")

</div>

I’m trying to sent a file to the iphone (which requires byte-range  
request support) using the rails send\_file method. However, this  
fails, I think because of mongrel. I think so because if I send the  
iphone a file handled by nginx, it plays it fine. But then when I  
serve the file with rails the iphone can’t play it.

Any ideas?

Alex

---

<div class="post-metadata">

**Author:** ![equinox86](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/4af34b/32.png) [@equinox86](https://www.ruby-forum.com/u/equinox86)\
**Post date:** [November 8, 2007, 6:06pm UTC](https://www.ruby-forum.com/t/byte-range-requests/119592/2 "2007-11-08T18:06:31Z")

</div>

On Nov 8, 2007, at 10:43 AM, Pete DeLaurentis wrote:

> I know that Lighttpd + Apache support X-Send-File, although I’m not  
> sure about nginx.

It does, though it’s inexplicably called X-Accel-Redirect.

[http://wiki.codemongers.com/NginxXSendfile](http://wiki.codemongers.com/NginxXSendfile)

[http://blog.kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/](http://blog.kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/)

-Nate

---

<div class="post-metadata">

**Author:** ![equinox86](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/4af34b/32.png) [@equinox86](https://www.ruby-forum.com/u/equinox86)\
**Post date:** [November 8, 2007, 5:44pm UTC](https://www.ruby-forum.com/t/byte-range-requests/119592/3 "2007-11-08T17:44:17Z")

</div>

Hi Alex,

Check out the x\_send\_file plugin. When you use this to send a file,  
it just sends the location on disk to the web-server (in a special  
HTTP header).

The webserver then looks up the file + streams it down to the  
client. I’ve noticed a huge speed boost after switching to x\_send\_file.

Since you observed that files sent by nginx work on your iPhone, this  
would allow nginx to do the heavy lifting for you.

I know that Lighttpd + Apache support X-Send-File, although I’m not  
sure about nginx.

Hope this helps,  
Pete

---

<div class="post-metadata">

**Author:** ![equinox86](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/4af34b/32.png) [@equinox86](https://www.ruby-forum.com/u/equinox86)\
**Post date:** [November 8, 2007, 8:26pm UTC](https://www.ruby-forum.com/t/byte-range-requests/119592/4 "2007-11-08T20:26:21Z")

</div>

Thank you for the clarification!

---

<div class="post-metadata">

**Author:** ![equinox86](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/4af34b/32.png) [@equinox86](https://www.ruby-forum.com/u/equinox86)\
**Post date:** [November 8, 2007, 8:24pm UTC](https://www.ruby-forum.com/t/byte-range-requests/119592/5 "2007-11-08T20:24:01Z")

</div>

On 11/7/07, Alex E. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’m trying to sent a file to the iphone (which requires byte-range  
> request support) using the rails send\_file method. However, this  
> fails, I think because of mongrel. I think so because if I send the  
> iphone a file handled by nginx, it plays it fine. But then when I  
> serve the file with rails the iphone can’t play it.

The other suggestions about using x\_send\_file or the equivalent are  
the answer, but just to clarify, Mongrel does not currently support  
byte-range requests. We have discussed adding support for that,  
however.

Kirk H.

---

<div class="post-metadata">

**Author:** ![equinox86](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/4af34b/32.png) [@equinox86](https://www.ruby-forum.com/u/equinox86)\
**Post date:** [May 14, 2010, 6:09pm UTC](https://www.ruby-forum.com/t/byte-range-requests/119592/6 "2010-05-14T18:09:40Z")

</div>

Pete DeLaurentis wrote:

> Hi Alex,
> 
> Check out the x\_send\_file plugin. When you use this to send a file,  
> it just sends the location on disk to the web-server (in a special  
> HTTP header).
> 
> The webserver then looks up the file + streams it down to the  
> client. I’ve noticed a huge speed boost after switching to x\_send\_file.
> 
> Since you observed that files sent by nginx work on your iPhone, this  
> would allow nginx to do the heavy lifting for you.
> 
> I know that Lighttpd + Apache support X-Send-File, although I’m not  
> sure about nginx.
> 
> Hope this helps,  
> Pete  
> Hi, is it possible to http-stream seekable mp4 videos with  
> X-Accel-Redirect? Or do I need to add some plugin or other stuff as  
> well? I am targetting the new html5 tag and the iPhone.

Cheers,
