Using an upstream header value as a proxy_cache_key

Maxim Dounin mdounin at mdounin.ru
Fri Dec 25 02:34:23 MSK 2009


Hello!

On Thu, Dec 24, 2009 at 03:28:25PM -0800, Troy Hakala wrote:

> Is it possible to have an upstream server set an HTTP header 
> that can be used as the key in proxy_cache_key? This doesn't 
> work:
> 
>                 proxy_cache_key $upstream_http_x_myheader;
> 
> And neither does this:
> 
>                 set $v $upstream_http_x_myheader;
>                 proxy_cache_key $v;

It won't, as $upstream_* variables are available only after 
request to upstream while cache key must be constructable from 
client request (before request to upstream, to find out if it's 
needed).

Maxim Dounin



More information about the nginx mailing list