Hats like to be worn in all normal kinds of weather. But no hat enjoys being soaked, baked or frozen. If it gets rain-soaked, allow it to air dry. If a straw hat becomes dehydrated, gently mist spray it with water or take it into a steamy bathroom for a few minutes. Then let it air dry. If it becomes drenched in sweat, let it air dry and then use a damp cloth or disinfectant wet tissue to clean up any grease and deal with the salt marks as best you can.
Fur felt hats are highly water resistant. For added protection against the elements, use Scotchgard or equivalent spray. The rain will then more or less roll off. Wool felt hats, on the other hand, do not like rain and will easily shrink. Waterproofing spray will delay, but not prevent, shrinkage in wool felt. Panama hats can be cautiously sprayed, in order to prevent dirty marks.