Recursively create cache-dir with decent permissions

I try to consolidate all my disk-based caches under a single parent folder and noticed that this one was having trouble being created. This patch will make it so that parent directories of the cache directory are created automatically. In addition, it ensures that group/other users do not have write permissions to the cache directory or its parents.