Headaches after training in heat, just dehydrated?

It seems having the electrolyte during the ride rather than 2 hrs after once you get a headache works better!