A quote from official nginx wiki on location block on The order in which location directives are checked..
Directives with the "=" prefix that match the query exactly (literal string). If found, searching stops.
All remaining directives with conventional strings. If this match used the "^~" prefix, searching stops.
Regular expressions, in the order they are defined in the configuration file.
If #3 yielded a match, that result is used. Otherwise, the match from #2 is used.
The rules from W3TC, may have taken precedence. That's why I mentioned the above possible solution. I hope you can understand.