Staying away from food is harder for me, but I've managed to avoid the Starbucks (YUM) that is in my MIL's hospital.
When I got pregnant, I wanted to do everything right...including avoiding coffee. What I did was, is reduce my intake by an 1/8 cup a day (after writing down how much I averaged a day).
Worked like a charm.
THEN, whenever I did get a headache, I drank just a half-cup of coffee for relief, instead of taking aspirin.
(Of course, this was before all this present health knowledge, btw)