Eli5: Why is caffeine often recommended for headache relief?
Headache is often a sign of caffeine withdrawal so drinking caffeine will help with the headache in that circumstance. Caffeine constricts your blood vessels so if you stop drinking it the vessels expand, causing pain. If you suffer through it for long enough the headache will eventually go away on its own
It also increases the rate of cerebrospinal fluid (CSF) production, which in certain circumstances (post-dural puncture headache, dehydration…) can improve a headache. Low CSF (the fluid that cushions your brain) can cause tugging on the meninges, thus causing pain.
Many headaches caused by your blood vessels expanding and creating pressure in your head. Caffiene make the blood vessels shrink, reduces the headache. Other things that might help, drinking water. But especially if the headache is from caffeine withdrawal, caffeine helps.
Edit: typed headache twice instead of caffiene
Edit: I got this backwards. Comment below me has a link that explains caffeine is a vasoconstrictor that relieves headaches caused by swollen blood vessels.
Caffeine is a vasodilator, meaning it causes your blood vessels to expand. This counteracts vasoconstriction, or the shrinking of blood vessels which is a common cause of headaches.