Changing some of your eating habits can prevent and even treat these conditions. There are many studies and research that show the connection between headaches and food. Some foods like brown rice, greens, and fruits have the amazing ability to prevent migraines and headaches.