I believe your hat or cap will be squeaky clean. The tag inside the cap should tell you whether the cap is machine washable. If it is, make sure you pre-treat any stains on it and then wash it in a cold or warm cycle with other clothes. See www.ehow.com/how_2081942_wash-baseball-cap.html for details.
When I have washed caps in washing machine by mistake they have fallen apart due to glued parts and worn out fabric. I heard you can wash them in the dish washer so I tried it, using one of the plastic cap frames. They did not get completely clean but at least stayed in one piece!
If it's a side loading machine, it gets clean. Just pop it in and out she comes. A top loading machine with an agitator post beats it up. I always air dry it. I usually put it on a bowl or a vase or overturned pot, something that will do what a frame does to give it shape.