nginx map is a lookup table, not a conditional

if inside a location is famously unreliable, and most uses of it are really a lookup — this value maps to that value — which map expresses directly and evaluates lazily.

map $http_user_agent $is_bot {
    default        0;
    "~*bot|crawl"  1;
}

map $request_method $purge_allowed {
    default  0;
    PURGE    1;
}

Blocks live at http level and the variable is only computed where it is used, so an unused map costs nothing. Regular expressions are matched in order and the first wins, with default as the fallback. It replaces most of the cases people reach for if for, and the ones it does not replace are usually better solved by a different location.