Make the cache more resilien to problems and fix local dir permission.