cache depth value from path for better performance