The best way to prevent migraines is to learn what sets them off and then try to avoid these triggers. Take a break from activities that provoke a migraine, such as using the computer for a long time. If you know that certain foods trigger your migraines, try to avoid them. Some people find that cutting back on caffeine intake or drinking a lot of water can help prevent migraines.
Make a plan for all the things you have to do — especially during stressful times like final exams — so you don't feel overwhelmed when things pile up. Regular exercise and fun activities can also reduce stress and make you feel better. If your doctor has prescribed medication, always have a dose on hand. Then if you feel a migraine coming, take your medicine. You can also try lying down in a quiet, dark room until the pain starts to go away.
The key is a diary. Migraines are so different for different people, so it helps to keep a headache diary and get to know what provokes migraines in your own case. The more you understand your headaches, the better prepared you can be to fight them.