Clearing cache causes nginx error Whenever I clear cache from the admin panel (or hit the url directly) I receive an nginx error (but nothing specific is being logged). 

There are no PHP error logs being created for this either. 

I've narrowed it down to the /includes/menu.inc _menu_router_build function.

The strange thing is, that if I add an echo to line 2365:

// Apply inheritance rules.
foreach ($menu as $path =&gt; $v) {
   echo $path; // echo added
   ....
}


The cache clears, it doesn't error out, BUT it doesn't seem to complete because all the values are echoed but I'm never redirected. Completely lost on this one.
We had a similar issue and traced it to the nginx fastcgi_read_timeout option. Because the code to clear the cache doesn't send any output to the browser until it finishes, nginx doesn't receive anything from PHP for 60 seconds. At this point, the default fastcgi_read_timeout is reached, so nginx aborts the request.

When you added the echo $path, you forced PHP to output something, which meant that nginx had something to read, so it didn't reach the timeout.

You should try increasing the fastcgi_read_timeout to, say, 120s and see if that helps.