Using an upstream header value as a proxy_cache_key

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;

Thanks!

Hello!

On Thu, Dec 24, 2009 at 03:28:25PM -0800, Troy H. 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 D.

Duh! That makes sense. :slight_smile: Thanks.