For example:

proxy_cache_key $request_uri$cookie_foo $request_uri: / $cookie_foo: foo => /foo $request_uri: /foo $cookie_foo: '' => /foo 

As a result, we get two identical keys for completely different requests. The task is to isolate the components of the key by 100% in order not to think at all that they can mix.

The use of a space (which, by the way, are cut out with empty values, which confuses everything even more), another character or string as a separator is 100% such matches do not exclude. Only if you do not generate such a boundary at every request and make sure that it is not present in every component of the key ...

  • "${request_uri}:::${cookie_foo}" - nörbörnën
  • @norbornen Well, that is just use three colons as a delimiter? - Maxim Yaskov
  • Anything that is unlikely to occur in your urlah and cookies. - Alexey Ten
  • @MaximYaskov, take the built-in perl or nginScript, if you need programism to generate a key. If, to solve your problem, this is an overhead, then it is enough to come up with a separator, the meaning of which was well revealed by Alex Ten. You can write at least req=${request_uri}, cookie=${cookie_foo} - nörbörnën
  • I think as a separator you can quite safely use the symbol | . In fact, the separator may be present in the key component elements, but in order to avoid generating identical keys for different requests, separators should not occur in an arbitrary number at the ends of at least two adjacent key elements (or elements between which empty values ​​are possible). - Maxim Yaskov

0