utils: Refactor file_exists to cache both existing and non-existing files

Slight performance improvement.