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

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:
https://forum.nginx.org/read.php?2,263611,263611#msg-263611

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs