A jog a day could keep your headaches at bay: Regular cardio workouts may prevent migraines, a growing body of research suggests. 

Migraine patients had fewer headaches after doing 40-minute cycling workouts three times a week for three months, according to a Swedish study. 

(For more than 2,000+ tips on how to live a healthier, longer, more kickass life, check out The Better Man Project.)

The exercise routine worked just as well as one of the top migraine-preventing drugs, topamirate—but without the side effects of depression, tremors, and cognitive impairment.

Aerobic workouts can help with regular headaches, too, says Alexander Mauskop, M.D., director of the New York Headache Center in Manhattan. 

There are a couple theories on how it works. 

Breaking a sweat may relieve stress, says Dr. Mauskop. Headaches are often triggered by stress, and if you eliminate the trigger, you nix the pain. 

It could also be endorphins at work, he says. The feel-good chemicals produced when you exercise actually block your pain sensors, acting as a natural painkiller. 

Related: 10 Crazy Reasons You Have a Headache

Since headaches can be caused by many different factors like genetics, lack of sleep, or certain foods, cardio won’t be the solution for everyone, Dr. Mauskop says. But one German study found that it helped 65 percent of patients—which makes it as effective as the best meds on the market.

Dr. Mauskop recommends his patients do a half-hour of moderate-intensity cardio, like jogging, biking, or swimming three times a week. These workouts are meant to be slow and steady, as opposed to high-intensity intervals that alternate between all-out sprints and rest.

(Consider hopping on one of these Best Cardio Machines on the Planet.)

Overexerting yourself or increasing the intensity too quickly can trigger headaches in some people, so make sure your heart rate doesn’t jump above 150 BPM. If you don’t have a heart rate monitor, then breathe exclusively through your nose. You'll know you're going too hard if you can't maintain that breathing pattern.

Your migraines could start disappearing in a couple of weeks, Dr. Mauskop says.