Lock the cache file while writing to prevent partial reads
Merge branch 'lock-cache-file'