S
S
Sergey Savostin2015-01-21 13:06:32
Nginx
Sergey Savostin, 2015-01-21 13:06:32

Why might Nginx not cache in this case?

I proxy requests to a third-party server (don't ask why).

http
{
proxy_cache_path /var/lib/nginx/cache/proxy/jpegs levels=1:2 keys_zone=jpegs:100m max_size=1G;
proxy_ignore_headers Expires Cache-Control;
}
....
server {
   location ~ ^/([a-f0-9]+)/(\d+)\.jpg$ {
   proxy_cache jpegs;
   proxy_cache_valid any 1m;
   proxy_cache_valid 404 1m;
   proxy_cache_min_uses 1;
   proxy_cache_key $uri;
   proxy_cache_bypass $cookie_nocache $arg_nocache$arg_comment;
   proxy_hide_header  Set-Cookie;
   if ( -f /path_to/$1 ) { # просто проверочка на доступ
      rewrite ^/[a-f0-9]+/(\d+) /remote_path/$1.jpg break;
      proxy_pass http://remoteserver.com;
      }
   }
}

The picture shows, but the cache folder is empty.
CHADNT?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Savostin, 2015-01-21
@savostin

I think I found the reason: remoteserver.com returns no-cache and it looks like nginx listens to it and does not cache it.
How can this be bypassed? As I understand proxy_cache_bypass refers to client requests, not requests to remoteserver?

V
Vit, 2015-01-21
@fornit1917

proxy_ignore_headers try
nginx.org/en/docs/http/ngx_http_proxy_module.html#...
serverfault.com/questions/642102/how-to-set-nginx-...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question