No, cavities should be treated before whitening because whitening materials can penetrate the cavities and damage the inner structure of the teeth.