proxy_cache_valid depending on $host

Maxim Dounin mdounin at mdounin.ru
Mon Jan 25 16:39:01 UTC 2021


Hello!

On Mon, Jan 25, 2021 at 04:26:49PM +0000, Phil Endecott wrote:

> Dear Experts,
> 
> I wanted to write this:
> 
> proxy_cache_valid 200 5m;
> if ($host ~ foo) {
>    proxy_cache_valid 200 30d;
> }
> 
> but proxy_cache_valid is not allowed in "if" blocks.
> Is there some work-around to have different cache validity times
> for different hosts, in a caching proxy?

Using different server{} blocks with different server_name's is the 
way to go, see http://nginx.org/r/server_name.

-- 
Maxim Dounin
http://mdounin.ru/


More information about the nginx mailing list