More smart raw_docs caching algorithm