Person holding a mug of coffee in bed

Like all vices, caffeine has been the target of some pretty major skepticism over the years. Nobody is sure, definitively, what to make of caffeine, reports CNBC. One USA Today headline boldly reads, "Alcohol and coffee can help you live past 90, study says." Other sources like this Reuters article link caffeine to hallucinations. Can both be true? Maybe. But, one thing is for sure, coffee keeps you jazzed. It’s why coffee giants can boast things like "America Runs on Dunkin‘" and nobody has to question it. Or, consider Caribou Coffee‘s literal slogan of "Life is short. Stay awake for it."

Whether you’re a fanatic, a critic, or someplace in between, caffeine is a drug you can get at any corner bodega. However, the key factor for safe, smart caffeine consumption might not be whether you sip a mug of joe before a meal or if you mix it with alcohol. To be a caffeine connoisseur, one of the most important things to keep in mind is how many hours before bedtime you’re ordering that large soy no-foam latte.

How caffeine affects the body

Arms holding up a cup of coffee and an alarm clock from bed

Caffeine is a naturally-occurring substance found in plants like cocoa and coffee beans or tea leaves, says AASM Sleep Education. It’s also a stimulant that takes effect in the body very quickly, as fast as within a half hour after ingesting. It works by stimulating the central nervous system, heart, muscles, and blood pressure, explains WebMD. Once ingested, caffeine has a half life of up to 5 hours in the body, meaning you might be able to feel that cuppa joe long after taking the first sip.

In moderation, caffeine boasts a number of health benefits: It can fight off diabetes, stroke heart failure, liver cancer, neurological diseases like Parkinson’s and Alzheimer’s, and even promote glucose production in the body, per John Hopkins University School of Medicine. It might even be able to protect you from COVID-19.

According to MedlinePlus, adults with no underlying health problems can safely consume up to 400 mg of caffeine every day. However, beyond that, the effects of too much caffeine can include restlessness, insomnia, shakiness, dehydration, anxiety, headache, dizziness, increased heart rate, and even chemical dependency.

Coffee can throw off your circadian rhythm

Mug of coffee atop a stack of books on a bed

According to the Sleep Foundation, a person’s circadian rhythm is the 24-hour internal clock that dictates their sleep-wake cycle. Even though circadian rhythm is inherently biological, it’s heavily influenced by environmental cues (which is why we get sleepy when the sun goes down, and why some organisms are nocturnal).

A study by Tina M. Burke and her team at University of Colorado Boulder found that caffeine "inserts a delay" into your biological clock, via Science.org. After studying five people for 49 days, Burke and co. observed that drinking a double-espresso three hours before bedtime shifted their test subjects’ natural circadian rhythms by 40 minutes. In the Journal of Clinical Sleep Medicine, Christopher Drake, Ph.D. reported that consuming caffeine six hours before bed could reduce sleep time by as much as an entire hour.

Similarly, biochemist Oren Froy reports that circadian rhythms regulate metabolism, via Oxford, meaning disrupted or irregular circadian rhythm could lead to obesity. Harvard reports that an improper sleep-wake cycle is directly linked to many psychological conditions such as anxiety, depression, seasonal affective disorder, and bipolar disorder. Maintaining a healthy, consistent circadian rhythm is an integral part of physical and mental wellbeing.

According to Better Health, your morning drip coffee packs 80-120 mg of caffeine, and your afternoon latte hits 110 mg. Even a cup of black tea before bed can carry as much as 105 mg of caffeine. Before you take a sip, spare a glance at the clock.