Caffeine can trigger headaches, but it can also relieve them. Caffeine is a vasoconstrictor that causes blood vessels to narrow and restrict the flow of blood. This can help reduce headache pain. When caffeine is combined with nonsteroidal anti-inflammatory drugs (NSAIDs) such as aspirin or ibuprofen, studies have shown that the pain relief is boosted by up to 40%.
Having a cup of coffee when you feel a headache coming on may be helpful, but remember, too much caffeine, or rather the withdrawal of caffeine, can also cause headaches. If you have been drinking a lot of caffeine and you stop or slow down your consumption, your body can go into withdrawal and you can get a headache as a result. If you are planning on reducing your caffeine intake, remember to do it slowly!