Welcome! Log In Create A New Profile

Advanced

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

Lucas Rolff
November 14, 2018 01:52PM
Hi Roman,

I can confirm that indeed does fix the problem, thanks!

I do wonder though, why not let nginx make the decision instead of relying on what the origin sends or does not send?

Thanks!

´╗┐On 14/11/2018, 17.36, "nginx on behalf of Roman Arutyunyan" <nginx-bounces@nginx.org on behalf of arut@nginx.com> wrote:

Hi,

On Wed, Nov 14, 2018 at 02:36:10PM +0000, Lucas Rolff wrote:
> 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?

The "proxy_force_ranges" directive enables byte ranges regardless of the
Accept-Ranges header.

http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_force_ranges

--
Roman Arutyunyan
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx


_______________________________________________
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: 70
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