Use /g (global) regex modifier in map

Maxim Dounin mdounin at
Fri Aug 8 16:14:52 UTC 2014


On Fri, Aug 08, 2014 at 05:06:55PM +0200, Gabriel Arrais wrote:

> Hi Maxim, first thank you very much for your answer!
> Maxim Dounin wrote in post #1154662:
> > Hello!
> > ...
> > Note well that even if you'll be able to filter arguments, there
> > is an additional problem of order of the arguments.
> >
> The same problem would occur using the variable $args right?


> > Simpliest way to normalize arguments is to use all of them in
> > proxy_cache_key, like this:
> >
> >     proxy_cache_key $proxy_host$uri$is_args$arg_foo:$arg_bar;
> >
> I've tried this, but it seems that nginx only catches the first 
> occurence of the parameter, resulting in 2 different requests cached 
> with the same key.
> Example:
>         ?fq=xxxxxx&sm=0&PageNumber=1     and
>         ?fq=xxxxxx&sm=0&PageNumber=1&fq=yyyyyyyyyy
> Are returning the same content. Is there a way to avoid this behavior?

There is no easy one, as nginx itself doesn't know how to work 
with multiple arguments with the same name.  You may try to build 
a regex to extract second argument with the given name (3rd, 4th, 
and so on) and include these into the cache key as well.

Maxim Dounin

More information about the nginx mailing list