Simple question about proxy cache

John Moore grails at jmsd.co.uk
Sun Mar 17 20:08:39 UTC 2013


I've used nginx as a reverse proxy server for a long while but I've not 
tried out the proxy cache until today, and I have to say I'm a little 
bit confused by what I'm seeing in the cache log, and I'm wondering 
whether I've set things up correctly. My requirements are actually 
pretty simple. I have a couple of locations which I want to proxy to 
another server and cache the results. Thus:

           location /media/house_images/{
             proxy_pass http://backend;
             proxy_cache one;
          }

          location /media/boat_images/{
             proxy_pass http://backend;
             proxy_cache one;
          }


Apart from this, I don't want any cacheing of responses to be done. I am 
assuming that the default is NOT to cache unless a cache zone is 
specified (at the server or location level, presumably), so either 
omitting a proxy_cache or specifying 'proxy_cache off' should be 
sufficient to achieve this, should it not?

Two things are puzzling me, though. Firstly, in the cache log, I'm 
seeing the URLs of all kinds of requests which SHOULD NOT be cached, and 
I'm wondering whether all requests are logged whether they're cached or 
not - I certainly hope this is the case and it's not actually cacheing 
these responses. I would definitely prefer to only see entries in the 
log for requests matching locations for which a cache has been 
specified. I presume this is possible?

Secondly, the very requests which I would expect to be cached are all 
showing up in the log with the word 'MISS' in the $upstream_cache_status 
column.

So, I am worried that I'm currently cacheing everything EXCEPT the pages 
I actually want to be cached!

Could someone please clarify whether my assumptions are correct, and 
maybe explain how I should set up cacheing to do just what I want, in 
the simplest way? Thanks.

John



More information about the nginx mailing list