I think it could make more sense to leverage this function here: 

https://github.com/dimagi/commcare-hq/blob/master/corehq/apps/hqwebapp/doc_info.py#L34

maybe we can add caching on top of it as well?