<br><br><div class="gmail_quote">On Thu, Jul 21, 2011 at 10:53 PM, David Yu <span dir="ltr"><<a href="mailto:david.yu.ftw@gmail.com">david.yu.ftw@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br><br><div class="gmail_quote"><div class="im">On Thu, Jul 21, 2011 at 10:43 PM, Igor Sysoev <span dir="ltr"><<a href="mailto:igor@sysoev.ru" target="_blank">igor@sysoev.ru</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div></div><div>On Thu, Jul 21, 2011 at 10:18:06PM +0800, David Yu wrote:<br>
> Hi,<br>
><br>
> I wanted to ask if the same regex used in multiple conditions is the same<br>
> cached-compiled version?<br>
> Eg I need to validate the all the (sub)request params before sending it<br>
> upstream:<br>
><br>
> location /foo {<br>
><br>
> if ($time !~ /(\d\d):(\d\d):(\d\d)/) { return 400; }<br>
> if ($arg_time !~ /(\d\d):(\d\d):(\d\d)/) { return 400; }<br>
><br>
> }<br>
><br>
> #note that in the real app, I'll have lots of repeated regex for email,<br>
> phone, used in every if directive<br>
><br>
> location /bar {<br>
><br>
> if ($arg_time !~ /(\d\d):(\d\d):(\d\d)/) { return 400; }<br>
> set_form_input $form_time time_finished;<br>
> if ($form_time !~ /(\d\d):(\d\d):(\d\d)/) { return 400; }<br>
><br>
> }<br>
><br>
> What I'm trying to do is send the params to redis with its lua scripting<br>
> engine handling the *pre-validated* request.<br>
> Redis is single-process while nginx can have multiple workers ... so its<br>
> only fitting to let nginx do validation for redis :-)<br>
<br>
</div></div>No, each regex is compiled separately.<br></blockquote></div><div>Thanks for the quick reply.</div><div>I'm thinking maybe the nginx map can act as the regex cache for the same ones.</div>
<div><br></div><div>set $map_regex_time $arg_time</div><div>if (!$map_regex_time) { return 400; }</div><meta http-equiv="content-type" content="text/html; charset=utf-8"><div><br></div><div>set_form_input $map_regex_time time_finished;</div>
<div>if (!$map_regex_time) { return 400; }</div></div></blockquote><div>Oops. Copy-paste err</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="gmail_quote">
<meta http-equiv="content-type" content="text/html; charset=utf-8"><div><br></div><div>Since I'll literally have hundreds of fields using the same regex, this might help?</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<font color="#888888"><br>
<br>
--<div class="im"><br>
Igor Sysoev<br>
<br>
_______________________________________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org" target="_blank">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a><br>
</div></font></blockquote></div><br><br clear="all"><div><div></div><div class="h5"><br>-- <br>When the cat is away, the mouse is alone.<br>- David Yu<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>When the cat is away, the mouse is alone.<br>- David Yu<br>