Caste system in India

I read an article recently about people in Uttar Pradesh refusing to eat free meals because the meals had been cooked by Dalits. I have seen references to losing one’s caste in other places. I presume this is what would happen if you ate food cooked by Dalits?

What do you have to do to lose your caste? What kind of consequences would it have for you in the caste system? Is there any way to get your caste back after losing it? How seriously is this sort of thing taken in India (or in Indian communities elsewhere) today?