it depends what material it is if it's wool/cotton like i believe most new era hats are i just hand wash it by soaking it in cold water and laundry detergent, then scrub it with a tooth brush how i keep my hat that i work construction in looking new.keep in mind after you wash a hat it's never the same like when you bought it if that makes sense.
You can put ball caps in the dishwasher or you can let it soak in the sink. My husband personally will not wear a hat until it has gone through the washing machine twice.