Answer the question
In order to leave comments, you need to log in
Why doesn't map work in nginx?
Here is such a design:
map '$request_method $query_string $http_cookie $request_uri' $cache_uri {
'POST ~* ~* ~*' null-cache;
'~* ~*(.+) ~* ~*' null-cache;
'~* ~* ~*(comment_author|wordpress_[a-f0-9]+) ~*' null-cache;
'~* ~* ~* ~*(/wp-admin/|/xmlrpc.php)' null-cache;
default $request_uri;
}
Answer the question
In order to leave comments, you need to log in
If you want a regular expression, then there must be one tilde at the beginning of the line
I think Aleksey Vinogradov wants to make a beautiful nginx config for WP Super Cache to work without a mountain of ifs, as in many articles like this one, which is commendable, because If is Evil
But apparently, in nginx map, the regular expression does not work for several values, so neither ~* nor ~(.*) nor ~^(.*)$ will work.
But I would call an nginx expert here to authoritatively either confirm my guess or refute it.
yes, I want for WP Super Cache. Tried one tilde at the beginning of the line. But then it looks like all 4 conditions are processed as a regular expression only to the first variable. In this case, the first condition in my construction does not work (the GET method and not POST), and the second condition always works. It seems that in map, regular expressions do not work with several variables, which is very unfortunate.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question