What actually occurs is that the blood vessels in your brain expand beyond their normal thresholds which puts pressure on the meninges (small nerves that cover the brain) which causes the painful headache. The headache subsides once the heart rate drops along with the blood pressure, but the headache lingers because the meninges remain extra sensitive.
Typically exertion headaches occur when a combination of the following circumstances are true:
1. You're Dehydrated: Dehydration thickens your blood
2. Valsalva (Holding Breath): This causes a dramatic spike in blood pressure
3. Poor Neck Position: Anything other than a neutral spine causes constrictions on the Carotid Arteries, the main arteries that deliver blood to the brain.
4. Increased Heart Rate: As a set progresses, your heart rate will steadily climb so that by the end of your set it can be close to (or above) your maximal heart rate.
5. Heavy Weight on Body: The more weight you have on your body, the more your blood pressure will rise as you exert yourself lifting it. Because legs are the strongest muscle group in the body, you typically lift more weight with your legs. The correlation with heavy weight and an increase in blood pressure makes compound leg movements more risky than other movements.
To prevent an exertion headache:
1. BE Hydrated: Drink enough water that you're piss is white the day before your lift and the day of, and drink water during your workout.
2. NEVER Hold Your Breath: Most good lifters pride themselves on having good form. When I'm working with a client, in addition to proper mechanics, I include proper breathing as a requirement for a rep to count. "Your holding your breath, that rep doesn't count."
3. Maintain a NEUTRAL SPINE: Unless you're performing a neck exercise, there is no need for your neck to be bent. Let it be comfortable and neutral and focus on the target muscle.
4. Allow for RECOVERY/ do CARDIO: First of all, do some cardio to condition your heart and lungs to be able to work hard. This will prevent the body from being too shocked on rep 9 and 10 on those Squats!
Second of all, give yourself enough time between sets and exercises for your heart rate to come down. You shouldn't jump in to the next set or exercise while your heart is pounding. Not only will you not perform as well because your cardiovascular system will fatigue before the muscle your training, but you will also put yourself at risk for the headache. As a general rule, any time you're doing a heavy compound movement, especially on legs, make sure your heart rate is comfortable before you begin the set.
5. Single-Leg, Single Joint / It is what it is: Try doing some single-leg leg extensions before you do your squats to pre-fatigue them so they go to failure sooner. Also, single joint leg movements can help you isolate the quads and ham strings so you can strengthen them through their entire range of motion which will help your Squat/Deadlift. However, it is what it is. As long as you can handle the heavy weight with good form, you should do it. It is what it is. Heavy weight on the squat bar/leg press/hack machine is GOING to cause an increase in your blood pressure. As long as 1-4 are good to go, move whatever weight you can control with good form.
Remember, an EXERTION HEADACHE is an INJURY TO THE BRAIN. If not taken seriously, it won't go away and can become worse. Just like any other injury in the gym, certain steps must be taken to transition the body back to a high performance level again.