Answer the question
In order to leave comments, you need to log in
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;
}
}
}
Answer the question
In order to leave comments, you need to log in
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?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question