TL;DR Much has been said about caffeine’s effect on headaches. Many say that it could cause migraine headaches, while others believe it could cure than do harm. But according to research, caffeine could in fact ease the pain from migraine because of two things – it has vasoconstrictive properties resisting blood flow, and that it speeds up the effectivity of painkillers. But too much caffeine could cause migraine too – mainly because of caffeine withdrawal and medication rebound.
Migraines can get so painful that people who suffer from them are often only able to do little, if nothing at all.
Migraine headaches are very common and are a major health problem globally. In the United States alone, there are about 38 million migraine patients - adults and children alike . That's about 1 in 4 households with people prone to migraines.
“Many people do not realize how serious and debilitating migraine can be,” the Migraine Research Foundation writes. “In addition to attack-related disability, migraine interferes with a sufferer’s ability to function in everyday life, whether that is going to school or work, caring for family or enjoying social activities.”
Moments before migraine strikes, blood vessels start to enlarge. What makes caffeine an effective pain reliever is its vasoconstrictive properties that restrict blood flow, narrowing the blood vessels and eventually helping ease the pain.
More importantly, caffeine speeds up relief because painkillers work a lot faster with it.  Caffeine boosts the efficacy of acetaminophen, aspirin, and ibuprofen by up to 40 percent,  given that there's 100 mg or greater of the stimulant consumed. 
Here's a fun fact: caffeine and pain relievers work so well together that some over-the-counter medicines contain caffeine. If you're curious, Cleveland Clinic listed down the various OTC's and the amounts of caffeine in each through this link: 
Caffeine also helps cure other types of headaches. A rare type called hypnic headaches are experienced by elderly people, waking them up with intense pain in the middle of the night.
Caffeine is especially helpful for treating hypnic headaches that doctors prescribe a cup of coffee when it strikes, or even before grandma and grandpa hit the hay!
But it’s a double-edged sword.
While caffeine helps provide a much-needed reprieve from migraines, it can also make them worse with over-consumption. These phenomena tell you that you've gone overboard:
Withdrawals. Loading up on caffeine a little too much can result in tremors, nervousness, and sleep interruptions. When you develop caffeine dependence, trying to get rid of it, even having less than your usual fix, can cause a headache. This is a clear symptom of withdrawals.
Here's a video that explains more:
A similar phenomenon is called caffeine rebound, which happens as part of withdrawal. While only 2 percent of the population suffers from it , caffeine rebound can cause a severe headache... even worse than a typical migraine!
Medication rebound can also take place, triggered by heavy dependence on pain relievers. With medication rebound, a headache with even more intense pain may start to form when the effects of pain medicine wear off.
Combining pain relievers with caffeine too often can make medication rebound even more likely. So it's good to take precautions when trying to mix caffeine with your go-to pain meds.
What are the precautions to keep in mind?
Each person reacts differently to caffeine, so it's important to know where to draw the line.
A good rule of thumb is to be aware of how caffeine affects us while keeping tabs of how much we take in.
Try to get your caffeine fix around the same time of the day. If you consume caffeine daily, please know that headache, irritability or sleepiness can take place if you don’t get your usual dose on time. Since caffeine makes blood vessels around the brain narrower, not getting your coffee or other caffeine sources around the same time can cause blood vessels to expand, leading to - wait for it - migraine.
Take the same amount of caffeine. Migraine sufferers prone to caffeine withdrawal should make sure to consume the same amount of caffeine with or without the headache. When a migraine strikes, avoid taking more caffeine than your usual fix! (Just keep to your usual dose.)
Have some caffeine at the start of a headache, not towards the end. Caffeine increases alertness and decreases fatigue. But when taking caffeine to help alleviate migraine, beware that caffeine can also keep you awake. If you're suffering from a migraine and nearing the end of the episode, avoid consuming caffeine altogether - a good restful sleep is just as badly needed.
It's good measure to get the "caffeine cure" at the start of the episode, not when it's about to end. To help you estimate when it's going to "end," migraine usually lasts anywhere between four to 72 hours. (Pro tip: try to remember how long the previous ones lasted.)
Take careful note of dosage. The labels of medications tell you how much of the drug should be taken per dose and per day and these guidelines should be strictly followed. Otherwise, say hello to medication rebound!
How much is too much? The National Headache Foundation advises that people who suffer from headaches should take no more than 200 mg of caffeine per day.
If it happens frequently for you, however, steer clear from taking caffeine daily and try to pace your consumption instead.
When in doubt, ask. Experts caution that before taking any medication or beginning a caffeine regimen, people who suffer from migraines should consult with their doctors and tell physicians about any drugs or supplements they are taking.
Erectile dysfunction. In combination, those are two of the ugliest words known to man. But can caffeine help you get it up?
Science hasn't found the definitive answer to this question, but one study concluded that fewer men who consume caffeine have problems performing. The study said:
Caffeine intake reduced the odds of prevalent ED, especially an intake equivalent to approximately 2-3 daily cups of coffee (170-375 mg/day). This reduction was also observed among overweight/obese and hypertensive, but not among diabetic men. Yet, these associations are warranted to be investigated in prospective studies