Factor out invalidate_previous_cache