Use /g (global) regex modifier in map
    Gabriel Arrais 
    lists at ruby-forum.com
       
    Fri Aug  8 18:27:54 UTC 2014
    
    
  
Maxim Dounin wrote in post #1154691:
> Hello!
>
> On Fri, Aug 08, 2014 at 05:06:55PM +0200, Gabriel Arrais wrote:
>
>> The same problem would occur using the variable $args right?
> Sure.
>
>> 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.
>
I think that it would end in a complicated solution this way...
Do you think that a perl code like
perl_set  $filtered_args '
  sub {
    my $r = shift;
    my $args=$r->args;
    my @parts = $args =~ /[DESIRED_REGEX]/g;
    @parts = sort @parts;
    $filtered_args = join("&", @parts);
    return $filtered_args;
  }
';
proxy_cache_key  $host:$uri?$filtered_args;
Will do the job?
I'm trying it right now.
Again, thank you for your time.
-- 
Posted via http://www.ruby-forum.com/.
    
    
More information about the nginx
mailing list