Better caching logic to ensure it pays attention to when the cache directory is inaccessible.