Almost two-thirds of American adults drink coffee each day, according to the National Coffee Association. And if you’re one of the millions who indulge regularly, you might be in luck. Research increasingly suggests that a coffee habit may have real health benefits.

Not only is coffee associated with short term perks like sharper focus and a better mood, it may help protect against serious medical conditions over the long term, including cardiovascular disease and some cancers. It’s even linked to a lower risk of all-cause mortality, or the odds of dying from any disease during a certain period of time.

What’s in coffee that might boost wellbeing? How exactly could a java habit benefit your health? And what can you do to optimize its possible positive effects? Here’s what you should know about coffee’s potential.

Your coffee’s chemical makeup, explained

“Coffee has hundreds of components,” says Miriam Zylberglait, MD, an HCA Healthcare internal medicine residency program director. And while each one may affect your health in some way, she explains, “Caffeine is the one that we know the most about.”

Caffeine is a chemical compound that stimulates your nervous system and influences the function of several others, including your cardiovascular, endocrine and digestive systems. A typical 8 ounce serving of black, brewed coffee contains about 100 milligrams (mg) of caffeine, though this amount can vary from cup to cup depending on preparation. A similar serving of decaffeinated coffee can have up to 15mg.

Since an excess of caffeine may have negative effects, experts often advise limiting yourself to a few cups of coffee per day. The U.S. Food and Drug Administration has said that 400mg of caffeine, the amount found in 4 or 5 cups, is generally safe for most people.

But coffee is more than just a caffeine delivery system. It contains small amounts of nutrients like potassium and magnesium, and is considered to be a good source of antioxidants. These powerful compounds help counteract inflammation, safeguard your cells from harm and may play a role in preventing disease. Polyphenols, for example, are plant-based antioxidants believed to help protect against cancer, among other illnesses.

The potential perks of java

“Medicine goes fast and furious,” says Zylberglait, and what we currently understand about coffee’s health effects could change in the future. That being said, experts believe both the short and long term benefits may be plentiful.

In the more immediate sense, coffee consumption is linked to increases in happiness, alertness, focus and energy. Studies also suggest it can boost athletic performance for a wide range of activities, from team sports to high-intensity workouts. Coffee stimulates muscles in the digestive system related to bowel movements, as well, and can alleviate pain stemming from headaches (though it can cause headache pain in some situations, too).

In the long run, researchers have found that coffee’s potential health advantages are dose dependent, meaning they hinge on how much java you regularly drink. Though the “ideal” amount varies by study and condition, habitual consumption is thought to affect the following illnesses in some way:

Cancer

Despite it being designated as a carcinogen by the World Health Organization up until 2016, coffee is not considered a cancer-causing agent. In fact, it may help protect against the development of certain malignancies. While research is ongoing, some studies suggest that consistent coffee use is linked to lower chances of liver, prostate, mouth, throat, skin and endometrial cancers.

Diabetes

Both caffeinated and decaffeinated coffee consumption are tied to a decreased risk of type 2 diabetes. The exact reason is unknown, but some experts think that certain compounds within coffee — perhaps polyphenols — could enhance insulin sensitivity and the metabolism of glucose.

Cardiovascular disease (CVD)

Moderate daily coffee intake has been associated with reduced chances of developing and dying from CVD. Compared to non-drinkers, people who drank 3 to 5 cups daily experienced a 15-percent drop in CVD risk, according to one 2013 meta-analysis. Another meta-analysis published in 2014, meanwhile, showed that sipping 3 cups per day was correlated to a 21-percent drop in CVD mortality. Research suggests that coffee consumption — caffeinated or decaffeinated — may also lower stroke incidence.

Depression

Coffee can exacerbate anxiety and insomnia, which may influence depressive symptoms. But some studies have connected moderate coffee use to lesser odds of developing depression when compared to low use or abstention. One theory is that antioxidants may alleviate inflammation, which is thought to contribute to depression.

Mortality

In many observational studies, drinking moderate amounts of coffee — often between 2 and 5 cups daily — has been correlated to a lower risk of mortality, or death from any illness. This could be partly due to the compounds within coffee, or because compared to non-drinkers, habitual coffee users are likelier to be healthier already.

In addition to these conditions, coffee consumption may also help safeguard against Parkinson’s disease, cirrhosis, gout and gallstones. The jury is out on coffee’s relationship to Alzheimer’s disease, however. Though some studies suggest caffeine may have a protective effect, others raise questions about the connection.

Worth noting: The bulk of research into coffee’s health effects is observational in nature. This means that while it may be safe to draw associations between coffee use and health benefits, it’s not possible, given the state of current research, to prove cause and effect.

Tips for optimizing your intake

To reap the potential health gains of coffee, it helps to keep a few things in mind.

First, beware of overdoing it. Among other issues, drinking too much java is linked to jitters, irritability, anxiety, insomnia and urge incontinence (a sudden urge to urinate followed by a loss of bladder control). People with certain health conditions may have additional problems, as well.

To note: Individual reaction to the caffeine in coffee differs from person to person, says Zylberglait, and depends on an array of factors, such as your weight, gender and genetics. Be aware of how your body responds to coffee use and report unusual symptoms or reactions to your healthcare provider.

Second, when you pour your morning (or mid-morning or afternoon) brew, go easy on sugar, higher-fat dairy, non-dairy creamers and other rich flavorings, which can add fat and calories and may counteract coffee’s health benefits. If you can’t stand black coffee and need to dress it up, use less sugar — or a lower calorie substitute — along with skim, unsweetened almond or unsweetened soy milk. Save tricked out seasonal lattes and blended drinks for special occasions.

Finally, understand that coffee is not a cure-all; simply drinking it won’t prevent disease or offset other unhealthy habits. “It’s not that if you smoke and you drink coffee, you will not have cancer,” says Zylberglait. “That shouldn’t be the message.”

Instead, consider coffee as part of an overall healthy lifestyle — one in which you eat a nutritious diet, get sufficient sleep and physical activity, avoid stressors and of course, don’t smoke.

This article originally appeared on Sharecare.com.