I can't say it's a cure all, but for me, hydration was key to avoiding migraines in my 20s-30s. Not just "drink until satisfied", but 1L by noon or a headache by 3-4pm. Losing weight helped reduce this, but still, hydration is a factor in 90% of my headaches.