Hi, looked around but couldn't find an answer: is there any way to have multiple conditions (a and b)/(a or b) in if statements. Or even nested if statements?
I have several checks in location using successive if statements using regexes, each of which sets a value as well. I think I can make things far more efficient by also checking if the value is already set or not. I'm assuming that like other languages, conditions will be evaluated from left-to-right and with shortcut evaluations (so if the first condition, which will be the faster condition to check if my flag is empty, is false, the second one doesn't need to be evaluated in case of an AND, or if the first one is true then the second one can be ignored in case of an OR). For example:
[code]
set $no_cache '';
if ($http_method = POST)
{
set $no_cache '1';
}
if ($request_uri ~ preview=true)
{
set $no_cache '1';
}
[/code]
...and so on...
in the second case, if the condition was:
[code]
if (!$no_cache AND $request_uri ~ preview=true)
{
...
}
[/code]
it would be much more efficient as I save a useless regex in case $no_cache is already '1'. And I have many such comparisions which happen uselessly.
Anyone?
Sumit.
Edited 1 time(s). Last edit at 06/16/2009 11:14AM by sumitg.