Cache exists and first when appropriate.

[ close #2667 ]