Add database-based caching to --download