# Proxy\_cache\_valid inheritance

**URL:** <https://www.ruby-forum.com/t/proxy-cache-valid-inheritance/190391>\
**Category:** NGINX\
**Created:** [June 19, 2010, 12:26am UTC](https://www.ruby-forum.com/t/proxy-cache-valid-inheritance/190391 "2010-06-19T00:26:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JSSSSrSSSSme\_Loyet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ee59a6/32.png) [@JSSSSrSSSSme\_Loyet](https://www.ruby-forum.com/u/JSSSSrSSSSme_Loyet)\
**Post date:** [June 19, 2010, 12:26am UTC](https://www.ruby-forum.com/t/proxy-cache-valid-inheritance/190391/1 "2010-06-19T00:26:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![JSSSSrSSSSme\_Loyet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ee59a6/32.png) [@JSSSSrSSSSme\_Loyet](https://www.ruby-forum.com/u/JSSSSrSSSSme_Loyet)\
**Post date:** [June 19, 2010, 1:27am UTC](https://www.ruby-forum.com/t/proxy-cache-valid-inheritance/190391/2 "2010-06-19T01:27:10Z")

</div>

Hi,

> I don’t know if setting proxy\_cache\_valid in location{} will totaly  
> overwritten proxy\_cache\_valid from http{} or just overwritten  
> specified values ?

First one. If you’ve got at least one “proxy\_cache\_valid” directive in  
your  
location {} block then only options set in that location {} block will  
be  
used. This rule applies to most of the nginx settings.

Best regards,  
Piotr S. \< [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) \>
