My mom used to buy these hat washer things. They were a plastic cage thing and you put your hat in it and actually threw it in the dishwasher. It helped the hats from shrinking.
I have done mine in the dishwasher, even without the cage, and it still comes out in much better condition than the beating it gets in the washing machine.
I work in a commercial kitchen and I've put many hats threw our conveyor dish machine. In the summer we would put them through the machine then throw them in the freezer and wear them to cool down. I've even put my shoes through the dish machine.