Welcome! Log In Create A New Profile

Advanced

Re: Same regex caching

David Yu
July 21, 2011 10:56AM
On Thu, Jul 21, 2011 at 10:53 PM, David Yu <david.yu.ftw@gmail.com> wrote:

>
>
> On Thu, Jul 21, 2011 at 10:43 PM, Igor Sysoev <igor@sysoev.ru> wrote:
>
>> On Thu, Jul 21, 2011 at 10:18:06PM +0800, David Yu wrote:
>> > Hi,
>> >
>> > I wanted to ask if the same regex used in multiple conditions is the
>> same
>> > cached-compiled version?
>> > Eg I need to validate the all the (sub)request params before sending it
>> > upstream:
>> >
>> > location /foo {
>> >
>> > if ($time !~ /(\d\d):(\d\d):(\d\d)/) { return 400; }
>> > if ($arg_time !~ /(\d\d):(\d\d):(\d\d)/) { return 400; }
>> >
>> > }
>> >
>> > #note that in the real app, I'll have lots of repeated regex for email,
>> > phone, used in every if directive
>> >
>> > location /bar {
>> >
>> > if ($arg_time !~ /(\d\d):(\d\d):(\d\d)/) { return 400; }
>> > set_form_input $form_time time_finished;
>> > if ($form_time !~ /(\d\d):(\d\d):(\d\d)/) { return 400; }
>> >
>> > }
>> >
>> > What I'm trying to do is send the params to redis with its lua scripting
>> > engine handling the *pre-validated* request.
>> > Redis is single-process while nginx can have multiple workers ... so its
>> > only fitting to let nginx do validation for redis :-)
>>
>> No, each regex is compiled separately.
>>
> Thanks for the quick reply.
> I'm thinking maybe the nginx map can act as the regex cache for the same
> ones.
>
> set $map_regex_time $arg_time
> if (!$map_regex_time) { return 400; }
>
> set_form_input $map_regex_time time_finished;
> if (!$map_regex_time) { return 400; }
>
Oops. Copy-paste err

>
> Since I'll literally have hundreds of fields using the same regex, this
> might help?
>
>
>>
>> --
>>
>> Igor Sysoev
>>
>> _______________________________________________
>> nginx mailing list
>> nginx@nginx.org
>> http://mailman.nginx.org/mailman/listinfo/nginx
>>
>
>
>
> --
> When the cat is away, the mouse is alone.
> - David Yu
>



--
When the cat is away, the mouse is alone.
- David Yu
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Same regex caching

David Yu July 21, 2011 10:20AM

Re: Same regex caching

Igor Sysoev July 21, 2011 10:46AM

Re: Same regex caching

David Yu July 21, 2011 10:56AM

Re: Same regex caching

David Yu July 21, 2011 10:56AM

Re: Same regex caching

Igor Sysoev July 21, 2011 02:12PM

Re: Same regex caching

David Yu July 21, 2011 09:24PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 324
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready