Caps suffer through a lot. Dirt and grime on the outside and sweat and oil on the inside from your scalp and brow. Even black hats can look pretty crappy after a while, while lighter colors can look really gnarly in no time—especially under the brim.
There is the fear that washing a hat will destroy its shape—especially the bill—and you've just wasted a nice lid, but unless you're rocking a really old one with cardboard bits, modern headgear isn't that maselan and is mostly made out of all sorts of synthetics which will outlast your presence on this planet. So here's the assurance you are no doubt waiting for: go ahead and dunk that sucker in the water, you'll be fine.
1) Prepare a warm or room temp bucket of water
2) Add a tablespoon of laundry detergent
No bleach! No fabric softener!
3) Dunk your hat in and use a toothbrush to gently brush off trouble spots
Obviously do not go HAM with the brush.
Optional: toothbrush a little shampoo onto the inner sweat stains. People on the Internet swear it works magic! But they never mention what shampoo they use so there's that. We say: shampoo is basically hair detergent anyway, give it a try if the sweat stains are real. It's on the inside anyway.
4) Let your headgear soak for an hour or so
You can check in for another spot cleaning if you're feeling OC.
5) Rinse well
6) Gently pat dry with a towel
Not a tissue unless you want to clean off a mess of itty bitty tissue bits afterwards
7) Airdry flat
With something vaguely-round underneath to keep its shape, use your imagination.