#871: Improve caching to not break on concurrent write access on the files.