break; usage

Jonathan Dance jd at agoragames.com
Thu Sep 6 23:52:37 MSD 2007


Thanks very much for the reply, Igor.
If I understand your explanation (which was most excellent), the blocks
would result in nearly identical results, but not because of the "break"
directive; it is identical because "proxy_pass" does not get inherited to
the "if" block. Additionally, since there are no rewrites, the "break"
directive has no effect. Is that correct?

It does sound like a refactoring is in order. In Igor we trust! :)

JD

On 9/6/07, Igor Sysoev <is at rambler-co.ru> wrote:
>
> On Thu, Sep 06, 2007 at 03:22:40PM -0400, Jonathan Dance wrote:
>
> > I was wondering if anyone could clarify what "break;" does - basically,
> does
> > it stop all processing, or only rewrite processing? What is its effect
> on
> > proxy_pass? Here are two simple contrasting examples:
>
> The "break" stops rewrite module processing only.
>
> > location / {
> >   if (!-f $request_filename) {
> >     proxy_pass http://somewhere;
> >     break; # does this do anything?
> >   }
> > }
>
> Here nginx runs "if" internal opcode, then "break" stops rewrite module
> execution. nginx uses static configuration inside "if" block.
> This configuration inherits all inheritable directives from previous
> levels (and defaults) and defines the single "proxy_pass" directive.
> So nginx will go to proxy module.
>
> > # Is that any different from this?
> >
> > location / {
> >   if (-f $request_filename) {
> >     break; # avoid the proxy_pass?
> >   }
> >   proxy_pass http://somewhere;
> > }
>
> Here nginx runs "if" internal opcode, then "break" stops rewrite module
> execution. nginx uses static configuration inside "if" block.
> This configuration inherits all inheritable directives from previous
> levels (and defaults). The "proxy_pass" directive is not inheritable,
> so nginx go to static module.
> If "if" condition was false, then nginx uses static configuration
> inside "localtion /", but outside "if", i.e. - "proxy_pass", etc..
>
> The current rewrite module state is ugly. This static configuration
> inside "if" blocks are terrible.
>
> I'm going to drop rewrite module and replace it with script module, that
>
> 1) will allow only to set variables inside "if" blocks
>
> 2) will allow to use script in different request processing phases:
>
>     location / {
>         script << {  # URI rewrite phase
>            ...
>         }
>
>         script {  # content generation phase
>            ...
>         }
>
>         script >> { # post content generation phase
>            ...
>         }
>
>
> --
> Igor Sysoev
> http://sysoev.ru/en/
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20070906/c6dcfc02/attachment.html>


More information about the nginx mailing list