Kicking the caffeine habit was what did it for me. Don't go cold turkey: I titrated slowly off the caffeine over the course of a month, and still had some withdrawal symptons (ie, headaches).
I still get headaches, but they're much less frequent, much less severe and it's usually much easier to track down the cause. (It's usually lack of sleep combined with too much screen time).
As a bonus, if I avoid computer & TV screens for the 2 hours before bed, I fall asleep within 30 seconds of my head hitting the pillow.
Sometimes when I'm focused I forget to eat, not sure if this is common among others but the concept of hunger doesn't always strike me if im in the zone. Remembering to eat and to eat healthy reduced the amount of headaches greatly.
I still get headaches, but they're much less frequent, much less severe and it's usually much easier to track down the cause. (It's usually lack of sleep combined with too much screen time).
As a bonus, if I avoid computer & TV screens for the 2 hours before bed, I fall asleep within 30 seconds of my head hitting the pillow.