Move cache directory creation code out of the constructor to avoid it being called on the UI thread