nginx + W3 Total Cache: rewrite rules issue [closed]

Solved.

Instead of

if (-f "$document_root/wp-content/cache/page_enhanced/$http_host/$request_uri/_index.html$w3tc_enc") {
  set $w3tc_rewrite 0;
}

should be

if (!-f "$document_root/wp-content/cache/page_enhanced/$http_host/$request_uri/_index.html$w3tc_enc") {
  set $w3tc_rewrite 0;
}

in W3 TC config.