extract cache path into function