Welcome! Log In Create A New Profile

Advanced

Byte-range request not possible for proxy_cache if origin doesn't return accept-ranges header

Lucas Rolff
November 14, 2018 09:38AM
Hi guys,

I've been investigating why byte-range requests didn't work for files that are cached in nginx with proxy_cache, I'd simply do something like:

$ curl -r 0-1023 https://cdn.domain.com/mymovie.mp4

What would happen was that the full length of a file would be returned, despite being in the cache already (I know that the initial request, you can't seek into a file).

Now, after investigation, I compared it with another file that I knew worked fine, I looked in the file on disk, the only difference between the two files, was the fact that one cached file contained Accept-Ranges: bytes, and another didn't have it.

Investigating this, I tried to add the header Accept-Ranges: bytes on an origin server, and everything started to work from nginx as well.

Now, I understand that Accept-Ranges: bytes should be sent whenever a server supports byte-range requests.
I'd expect that after nginx has fetched the full file, that it would be perfectly capable of doing byte-range requests itself, but it seems like it's not a possibility.

I'm not really sure if this is a bug or not, but I do find it odd that the behavior is something like: "If origin does not understand byte-range requests, then I also shouldn't understand them".

Is there a way to solve this on the nginx side directly to "fix" origin servers that do not send an Accept-Ranges header, or is it something that could possibly be fixed in such a way that nginx doesn't "require" the cached file to contain the "Accept-Ranges: bytes" header, to be able to do range requests to it?

Thanks in advance!

Best Regards,
Lucas Rolff
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Byte-range request not possible for proxy_cache if origin doesn't return accept-ranges header

Lucas Rolff November 14, 2018 09:38AM

Re: Byte-range request not possible for proxy_cache if origin doesn't return accept-ranges header

Roman Arutyunyan November 14, 2018 11:36AM

Re: Byte-range request not possible for proxy_cache if origin doesn't return accept-ranges header

Lucas Rolff November 14, 2018 01:52PM

Re: Byte-range request not possible for proxy_cache if origin doesn't return accept-ranges header

Roman Arutyunyan November 15, 2018 04:32AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 313
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready