<div dir="ltr">Great! =) Make sure proxy buffering stays on - that will bypass the cache if turned off, and make sure your key space is large because you'll throw 500s for everything if it runs out (I figured it would evict a key if it ran out of space, and what was a wrong assumption)<div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Mar 19, 2016 at 4:43 PM, Lucas Rolff <span dir="ltr"><<a href="mailto:lucas@slcoding.com" target="_blank">lucas@slcoding.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div text="#000000" bgcolor="#FFFFFF">Seems like it's resolved:<br>
<br>
$ curl -I 
<a href="http://dev.ts-export.com/kuriyamacache/images/parts/13375/thumbnail_0/1_1.jpg" target="_blank">http://dev.ts-export.com/kuriyamacache/images/parts/13375/thumbnail_0/1_1.jpg</a><span class=""><br>
HTTP/1.1 200 OK<br>
Server: nginx<br></span>
Date: Sat, 19 Mar 2016 20:42:46 GMT<span class=""><br>
Content-Type: image/jpeg<br>
Content-Length: 53491<br>
Connection: keep-alive<br></span><span class="">
Last-Modified: Thu, 10 Mar 2016 05:01:30 GMT<br>
ETag: "d0f3-52daab51fbe80"<br></span>
Expires: Sun, 19 Mar 2017 20:42:46 GMT<br>
Cache-Control: max-age=31536000<br>
Cache-Control: public, max-age=31536000<br>
X-Cache-Status: MISS<br>
Accept-Ranges: bytes<br>
<br>
$ curl -I 
<a href="http://dev.ts-export.com/kuriyamacache/images/parts/13375/thumbnail_0/1_1.jpg" target="_blank">http://dev.ts-export.com/kuriyamacache/images/parts/13375/thumbnail_0/1_1.jpg</a><span class=""><br>
HTTP/1.1 200 OK<br>
Server: nginx<br></span>
Date: Sat, 19 Mar 2016 20:42:48 GMT<span class=""><br>
Content-Type: image/jpeg<br>
Content-Length: 53491<br>
Connection: keep-alive<br></span><span class="">
Last-Modified: Thu, 10 Mar 2016 05:01:30 GMT<br>
ETag: "d0f3-52daab51fbe80"<br></span>
Expires: Sun, 19 Mar 2017 20:42:48 GMT<br>
Cache-Control: max-age=31536000<br>
Cache-Control: public, max-age=31536000<br>
X-Cache-Status: HIT<br>
Accept-Ranges: bytes<div><div class="h5"><br>
<br>
<span>CJ Ess wrote:</span><br>
<blockquote type="cite">
  <div dir="ltr">I think I've run into the problem before - move the 
proxypass statement from the top of the location stanza to the bottom, 
and I think that will solve your issue.<div><br></div></div>
  <div class="gmail_extra"><br><div class="gmail_quote">On Sat, Mar 19, 
2016 at 4:10 PM, shiz <span dir="ltr"><<a href="mailto:nginx-forum@forum.nginx.org" target="_blank">nginx-forum@forum.nginx.org</a>></span>
 wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Been playing with this
 for 2 days.<br>
<br>
proxy_pass is working correctly but the proxy_cache_path remains empty<br>
whatever I make.<br>
<br>
<br>
Here's the source I use for tests:<br>
root@NC-PH-0657-10:/etc/nginx/snippets# curl -X GET -I<br>
<a href="http://www.kuriyama-truck.com/images/parts/13375/thumbnail_0/1_1.jpg" rel="noreferrer" target="_blank">http://www.kuriyama-truck.com/images/parts/13375/thumbnail_0/1_1.jpg</a><br>
HTTP/1.1 200 OK<br>
Date: Sat, 19 Mar 2016 18:15:16 GMT<br>
Server: Apache/2.4.16 (Amazon) PHP/5.6.17<br>
Last-Modified: Thu, 10 Mar 2016 05:01:30 GMT<br>
ETag: "d0f3-52daab51fbe80"<br>
Accept-Ranges: bytes<br>
Content-Length: 53491<br>
Content-Type: image/jpeg<br>
<br>
Now here's the response from the nginx:<br>
root@NC-PH-0657-10:/etc/nginx/snippets# curl -X GET -I<br>
<a href="http://dev.ts-export.com/kuriyamacache/images/parts/13375/thumbnail_0/1_1.jpg" rel="noreferrer" target="_blank">http://dev.ts-export.com/kuriyamacache/images/parts/13375/thumbnail_0/1_1.jpg</a><br>
HTTP/1.1 200 OK<br>
Server: nginx<br>
Date: Sat, 19 Mar 2016 18:14:46 GMT<br>
Content-Type: image/jpeg<br>
Content-Length: 53491<br>
Connection: keep-alive<br>
Expires: Sun, 19 Mar 2017 18:14:46 GMT<br>
Cache-Control: max-age=31536000<br>
Cache-Control: public<br>
X-Cache-Status: MISS<br>
Accept-Ranges: bytes<br>
<br>
Here are the request headers from my browser:<br>
GET /kuriyamacache/images/parts/13375/thumbnail_1/1_1.jpg HTTP/1.1<br>
Host: <a href="http://dev.ts-export.com" rel="noreferrer" target="_blank">dev.ts-export.com</a><br>
Connection: keep-alive<br>
Cache-Control: max-age=0<br>
Accept:<br>
text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8<br>
Upgrade-Insecure-Requests: 1<br>
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 
(KHTML,<br>
like Gecko) Chrome/49.0.2623.87 Safari/537.36<br>
DNT: 1<br>
Accept-Encoding: gzip, deflate, sdch<br>
Accept-Language: fr-CA,fr;q=0.8,en-US;q=0.6,en;q=0.4,ja;q=0.2,de;q=0.2<br>
Cookie: PRUM_EPISODES=s=1458412951203<br>
<br>
Part of my setup:<br>
<br>
proxy_cache_path /tmp/nginx/dev levels=1:2 keys_zone=my_zone:10m<br>
max_size=10g inactive=60m use_temp_path=off;<br>
<br>
server {<br>
<br>
  set $rule_3 0;<br>
  set $rule_4 0;<br>
  set $rule_5 0;<br>
  set $rule_8 0;<br>
  set $rule_9 0;<br>
<br>
  server_name <a href="http://dev.ts-export.com" rel="noreferrer" target="_blank">dev.ts-export.com</a>;<br>
  listen 80;<br>
  listen [::]:80;<br>
<br>
  root /home/tsuchi/public_html;<br>
<br>
  if ($reject_those_args) {<br>
    return 403;<br>
  }<br>
<br>
  include snippets/filters.conf;<br>
<br>
  error_page 404 /404.html;<br>
<br>
  if ($request_uri ~ "^/index.(php|html?)$" ) {<br>
    return 301 $scheme://<a href="http://dev.ts-export.com" rel="noreferrer" target="_blank">dev.ts-export.com</a>;<br>
  }<br>
<br>
<br>
  # no SSL for IE6-8 on XP and Android 2.3<br>
  if ($scheme = https) {<br>
    set $rule_8 1$rule_8;<br>
  }<br>
  if ($http_user_agent ~ "MSIE (6|7|8).*Windows NT 5|Android 2\.3"){<br>
    set $rule_8 2$rule_8;<br>
  }<br>
  if ($rule_8 = "210"){<br>
    return 301 <a href="http://dev.ts-export.com" rel="noreferrer" target="_blank">http://dev.ts-export.com</a>$request_uri;<br>
  }<br>
<br>
<br>
  location = / {<br>
    allow all;<br>
  }<br>
<br>
  location = /robots.txt {<br>
    add_header X-Robots-Tag noindex;<br>
  }<br>
<br>
<br>
  location '/.well-known/acme-challenge' {<br>
    default_type "text/plain";<br>
    root        /tmp/letsencrypt-auto;<br>
  }<br>
<br>
  include snippets/proxyimg.conf;<br>
<br>
  location / {<br>
    try_files $uri $uri/ @rewrites;<br>
    allow all;<br>
  }<br>
 (...)<br>
}<br>
<br>
Contents of proxyimg.conf:<br>
<br>
 location ^~ /kuriyamacache {<br>
    expires 1y;<br>
    access_log off;<br>
    log_not_found off;<br>
    resolver 127.0.0.1;<br>
<br>
    proxy_pass <a href="http://www.kuriyama-truck.com/" rel="noreferrer" target="_blank">http://www.kuriyama-truck.com/</a>;<br>
<br>
    proxy_cache my_zone;<br>
    proxy_cache_key "$scheme$request_method$host$request_uri";<br>
    proxy_buffering on;<br>
<br>
    proxy_cache_valid  200 301 302  60m;<br>
    proxy_cache_valid  404      1m;<br>
    proxy_cache_use_stale error timeout http_500 http_502 http_503<br>
http_504;<br>
    proxy_cache_revalidate on;<br>
    proxy_cache_lock on;<br>
<br>
    proxy_set_header Host $host;<br>
    proxy_set_header   X-Real-IP        $remote_addr;<br>
    proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;<br>
<br>
    proxy_ignore_headers X-Accel-Redirect X-Accel-Expires 
X-Accel-Limit-Rate<br>
X-Accel-Buffering X-Accel-Charset Set-Cookie Cache-Control Vary Expires;<br>
<br>
    proxy_pass_header ETag;<br>
    proxy_hide_header Cache-Control;<br>
<br>
    add_header Cache-Control "public, max-age=31536000";<br>
    add_header X-Cache-Status $upstream_cache_status;<br>
<br>
  }<br>
<br>
Posted at Nginx Forum: <a href="https://forum.nginx.org/read.php?2,265504,265504#msg-265504" rel="noreferrer" target="_blank">https://forum.nginx.org/read.php?2,265504,265504#msg-265504</a><br>
<br>
_______________________________________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org" target="_blank">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" rel="noreferrer" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a><br></blockquote></div><br></div>


  <pre>_______________________________________________
nginx mailing list
<a href="mailto:nginx@nginx.org" target="_blank">nginx@nginx.org</a>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a></pre>
</blockquote>
<br>
</div></div></div>
<br>_______________________________________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" rel="noreferrer" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a><br></blockquote></div><br></div>