What's the science behind taking magnesium for headaches?

Headaches and migraines can be debilitating. So can taking magnesium for headaches relieve some of the discomfort?

What's the science behind taking magnesium for headaches?
Headaches and migraines can be debilitating. So can taking magnesium for headaches relieve some of the discomfort?