A nginx map is a lookup table that beats a chain of ifs

if inside a location block is famously unreliable in nginx, and a chain of them for what is really a lookup is both slow and surprising.

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

map $request_uri $cache_bypass {
    default          0;
    "~*/checkout"    1;
    "~*/cart"        1;
}

server {
    proxy_cache_bypass $cache_bypass;
}

A map is evaluated lazily — only when the variable is used — and it is a hash lookup rather than a sequence of tests, so it stays fast as it grows. It also lives at the http level, which means the same table serves every server block rather than being duplicated. The regular expression entries are tried in order after the exact matches, so putting the common cases as literals is worth doing when the table is large.