Add onError option and clear cache entry on error.