proxy_cache_valid inheritance

Jérôme Loyet jerome at loyet.net
Sat Jun 19 02:25:16 MSD 2010


Hi,

I have a question about the proxy_cache_valid inheritance. I have the
following configuration:

http {
  ...
  proxy_cache_valid 301                1h;
  proxy_cache_valid 200 302 404   10m;
  proxy_cache_valid any                 1m;
  ...
  server {
    proxy_cache mycache;

    location /test {
      proxy_pass http://$backend;
    }

    location /bar {
      proxy_pass http://$backend;
      proxy_cache_valid 5m;
    }

    location /foo {
      proxy_pass http://$backend;
      proxy_cache_valid 200, 301, 302, 404 5m;
    }
  }
}

In this conf:

- /test will be cache with 1h for 301, 10m for 200/302/404 and 1m for
the other types of response

How will be cahed requests to /foo ?
- 200, 301, 302 = 5m, others won't be cached ?
- 200, 301, 302 = 5m, 404 = 10m (as set in http{}) and others will be
cached for 1m (as set in http{}) ?

How will be cahed requests to /bar ?
- 200, 301, 302, 404 = 5m, others won't be cached ?
- 200, 301, 302, 404 = 5m, others will be cached for 1m (as set in http{}) ?

I don't know if setting proxy_cache_valid in location{} will totaly
overwritten proxy_cache_valid from http{} or just overwritten
specified values ?

Thx a lot
++ Jerome



More information about the nginx mailing list