Proxy_cache_key based on custom header

Francis Daly francis at
Fri Jun 30 16:26:46 UTC 2017

On Tue, Jun 27, 2017 at 05:43:22PM -0400, deivid__ wrote:

Hi there,

You will probably change your setup so that the default proxy_cache_key
works for you; but for information:

> If `proxy_cache` is set to `$sent_http_x_test_header`:
> - Every request gets cached (good)
> - All URLs map to the same cache (very bad!)
> - I don't get the 'X-Banana' header at all

The only useful content of proxy_cache_key is things that are known
*before* the matching proxy_pass request would be made. (Otherwise,
there is no way that a second request could be served from the cache,
avoiding the upstream connection.)

So $sent_* and $upstream_* variables should not be used, since they will
be empty.

Good luck with it,

Francis Daly        francis at

More information about the nginx mailing list