# Range + If-Range requests not working with proxy cache hits

**URL:** <https://www.ruby-forum.com/t/range-if-range-requests-not-working-with-proxy-cache-hits/243691>\
**Category:** NGINX\
**Created:** [December 21, 2015, 3:39pm UTC](https://www.ruby-forum.com/t/range-if-range-requests-not-working-with-proxy-cache-hits/243691 "2015-12-21T15:39:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rafa\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/958977/32.png) [@Rafa\_F](https://www.ruby-forum.com/u/Rafa_F)\
**Post date:** [December 21, 2015, 3:39pm UTC](https://www.ruby-forum.com/t/range-if-range-requests-not-working-with-proxy-cache-hits/243691/1 "2015-12-21T15:39:36Z")

</div>

Hello,

I’m using proxy\_cache module and I noticed nginx replies with whole  
response  
and 200 OK status on requests such as this and for content that is  
already  
in cache:

User-Agent: curl/7.26.0  
Accept: _/_  
Range:bytes=128648358-507448924  
If-Range: Thu, 26 Nov 2015 13:48:46 GMT

However, If I remove the “If-Range” request header, I get the correct  
content range in return.  
I enabled debug logging and was focused on this part of the code:

0207 if\_range\_time = ngx\_parse\_http\_time(if\_range-\>data,  
if\_range-\>len);  
0208  
0209 ngx\_log\_debug2(NGX\_LOG\_DEBUG\_HTTP, r-\>connection-\>log, 0,  
0210 “http ir:%d lm:%d”,  
0211 if\_range\_time,  
r-\>headers\_out.last\_modified\_time);  
0212  
0213 if (if\_range\_time != r-\>headers\_out.last\_modified\_time) {  
0214 goto next\_filter;  
0215 }

which I found to output:

2015/12/21 12:55:18 [debug] 13727#13727: \*716934 http ir:1448545726 lm:0  
2015/12/21 12:55:18 [debug] 13727#13727: \*716934 posix\_memalign:  
0000000004F32F50:4096 @16  
2015/12/21 12:55:18 [debug] 13727#13727: \*716934 HTTP/1.1 200 OK  
Server: nginx  
Date: Mon, 21 Dec 2015 12:55:18 GMT  
Content-Type: video/mp4  
Content-Length: 507448925  
Connection: keep-alive  
X-Powered-By: PHP/5.3.28  
Cache-Control: max-age=10368000, public  
Last-Modified: Thu, 26 Nov 2015 13:48:46 GMT  
…

As well as:  
$ head -20 /home/disk2/cache/e2/9a/611e43135479fdcc9e8eb5e507349ae2|grep  
-a  
Last  
Last-Modified: Thu, 26 Nov 2015 13:48:46 GMT

Given the info above, I’m confused about the “lm:0”. How come is it 0  
when  
in both cached file header and in the final response correctly set  
Last-Modified value. Am I missing something, do you know what might be  
causing this? Nginx is 1.8, proxy\_force\_ranges is unset and  
proxy\_set\_header  
doesn’t contain any relevant values. It doesn’t seem to be a big issue  
as  
adding Etag appears to help, but just wondering if you have any idea?

Thanks,  
Vedran

Posted at Nginx Forum:

> **[Range + If-Range requests not working with proxy cache hits](https://forum.nginx.org/read.php?2,263611,263611#msg-263611)**
>
> Hello, I'm using proxy\_cache module and I noticed nginx replies with whole response and 200 OK status on requests such as this and for content that is already in cache: User-Agent: curl/7.26.0 Accept: \*/\* Range:bytes=128648358-507448924 If-Range: Th
