How to Clean a Cap Without Wrecking the Crown
Do not put a structured cap in a washing machine, and never put one in a dryer. Heat and agitation are what destroy the crown, and once the structure has gone soft there is no restoring it.
Spot-clean instead. It takes longer and it works.
Spot-cleaning
Cool water, a small amount of mild detergent, and a soft brush or cloth. Work on the mark rather than the whole panel, blot rather than scrub, and rinse the detergent out with a clean damp cloth so it does not dry as a ring.
Wool needs more care than twill, go gentler, and accept that some marks will not come out entirely.
The sweatband
That is where most of the problem actually is. Cool water, mild detergent, soft brush, and let it dry completely before wearing.

Drying
Air-dry, away from direct heat. Stuff the crown with a towel or a ball of paper so it holds shape while it dries, and keep the brim flat rather than resting the cap on it.
Storage
Upright, not under other things. A structured crown will take a permanent dent if something sits on it long enough, and a flat brim will curve if you store it pressed against something.
What not to do
Machine wash. Tumble dry. Dishwasher, this circulates as advice and it is bad advice for anything with structure or wool in it. Bleach, on anything.
FAQ
Can I put a cap in the washing machine?
Not a structured one. Agitation and heat break down the crown, and the damage is permanent. Spot-clean instead.
How do I clean the sweatband?
Cool water, mild detergent and a soft brush. Let it dry completely before wearing.
How should I store a cap?
Upright and not under other things. A structured crown dents permanently under weight, and a flat brim curves if stored pressed.
Is the dishwasher method safe?
No. It circulates widely as advice and it is bad advice for anything structured or wool.