这应该可以解决问题:set $no_cache ""; if ($request_uri ~* \.gif$) { set $no_cache "1"; } proxy_no_cache $no_cache; proxy_cache_bypass $no_cache;
location
块内部。对于其他人,这里是关于if
的文档:http://wiki.nginx.org/NginxHttpRewriteModule#if。 - Oliver