Cache unsuccessful file lookups for improved performance.

This change improves performance on compilations that are heavy on file lookups, such as projects comprised of a large number of external modules.