and only cache intermediates when validation was succesful.