“If you’re a migraineur, it’s far better to prevent the headaches than to take drugs after the fact,” says Jason B. Rosenberg, MD, a headache medicine specialist and director of Johns Hopkins Headache Center at Johns Hopkins Bayview Medical Center. Rosenberg and other specialists recommend lifestyle changes, supplements, medications, and some therapies to stop migraines before they even start. While they won’t get rid of every headache, they should make them less frequent. Here, 7 ways to stave off an attack. Get healthy sleep.—The Hormone Reset Diet “Poor sleep is one of the largest recorded triggers of migraine, and bad sleeping habits are a risk factor for getting daily migraines,” says Rosenberg. He suggests using basic sleep hygiene tips, which have been shown to dramatically reduce migraine attacks. If you need a refresher, the Centers for Disease Control and Prevention suggests going to bed and waking up at the same time every day, making your bedroom a relaxing environment that’s dark and quiet, using your bed only for sleeping—not for reading, watching TV, or listening to music—and avoiding large meals right before bedtime. These habits will regulate your circadian rhythm, to help stave off migraines. (It can also help you lose weightlearn how to make it work for you with !) MORE: 20 Ways To Sleep Better Every Night Do aerobic exercise. A 2011 study in the journal Cephalalgia comparing different types of migraine prevention techniques found that regular exercise is just as effective as migraine medications at preventing attacks. Scientists believe that about 40 minutes of aerobic exercise three times a week releases feel-good chemicals like endorphins and increases the amount of oxygen in your body, which could help prevent the crushing headaches. Take in plenty of riboflavin. Riboflavin is a B vitamin that can be found in foods like milk, meat, eggs, nuts, enriched flour, and green vegetables. It’s also available as a supplement, which Robert Cowan, MD, clinical professor of neurology at Stanford School of Medicine, says has been effective in preventatively treating patients with chronic headaches. And a study published in the European Journal of Neurology backs that up: It found that 400 mg of riboflavin daily was associated with a decrease in the frequency of migraine headaches.   Don’t skimp on magnesium.NeuroSciences Most people who suffer chronic migraines have at least one thing in common—a magnesium deficiency, according to research including a 2011 study published in . Cowan suggests taking chelated magnesium supplements, a form of the mineral that improves absorption. But both Cowan and Rosenberg warn that magnesium could cause diarrhea. Consider abortive migraine medications. Doctors prescribe triptans, a pain reliever stronger than acetaminophen or aspirin, for people with frequent, acute migraines. Research has suggested that if taken at the first sign of an impending migraine (a stage called “prodrome”), triptans, especially naratriptan, can prevent the headache stage of migraine in about 60% of patients. Try temperature therapy.— A nice hot bath feels good anytime, but it might also wash away your migraine. Doctors at the Mayo Clinic say temperature therapy will sometimes stop a migraine in prodrome. They suggest applying hot or cold compresses to your head and neck as soon as you feel a migraine coming on. Although there’s not much research backing up temperature therapy, some doctors believe that the reason it works is by helping to relax the muscle tension that contributes to migraines. Cowan says most people prefer cold compresseswhich slow nerve conduction and decrease blood flow. But hot compresses or a warm bath or shower can also relax your muscles and relieve migraine. MORE: 16 Healing Herbs For The Most Amazing Bath Of Your Life Give biofeedback and relaxation therapy a go. Biofeedback therapists monitor your body’s responses with electrical feeds or thermometers and teach you how to recognize symptoms of stress so you can relax (learn more about biofeedback here and find a practitioner here). This type of therapy can help people whose migraines stem from stress or tension recognize triggers for their headaches and teach them methods like learning to stay calm in stressful situations, which can prevent future attacks.