I think it takes someone who is self confident to abate any rude or snide comments.
For me, it's still important to not let such comments go completely

IF it's with someone I have to have contact with again in time. ( If it's a stranger, it's quite easy to ignore them.) I found that, for me, ignoring comments like that or making reinforcing comments only feeds them with assurance that what they are saying and how they are saying it is acceptable.
I wish I could always look for the reason behind the comment that upsets me. Is it really an attack on me? Does it really change who I am? How are they feeling that they needed to say that? How can I help them work through this? Those types of questions are a main focus for me, when I'm able to cogitate in a situation.