Caching Content-based Queries for Robust and Efficient Image Retrieval