We've often wanted a coffee perhaps after work or even before bed, but for fear of it keeping us awake we usually steer clear.
A study carried out by US researchers from Florida Atlantic University and Harvard Medical School monitored the caffeine, nicotine and alcohol intake of 785 volunteers for 5,164 days using wrist sensors and sleep diaries.
It found that nicotine and alcohol disrupted sleep, with a late cigarette taking 42 minutes from the sleep of an insomniac, but that drinking caffeine within four hours of bedtime didn't have any affect.
Around 40 people in the study admitted to having caffeine on one night of the study, but the lack of disruptions was found to be baffling by the researchers, who noted that physiologically, caffeine promotes wakefulness by blocking chemicals in the brain that encourage sleep.
Writing in the journal, Dr. Christine Spadola, from Florida Atlantic University, said: "Considering the public health importance of obtaining quality sleep and the widespread use of alcohol, nicotine and caffeine, relatively few studies have thoroughly investigated the association between evening substance use and sleep parameters.
"This study represents one of the largest longitudinal examinations of the associations of evening use of alcohol, caffeine and nicotine with objectively measured sleep outcomes.
"A night with use of nicotine and/or alcohol within four hours of bedtime demonstrated worse sleep continuity than a night without.
"We did not observe an association between ingestion of caffeine within four hours of bed with any of the sleep parameters."
This said, the researchers also noted that they were unable to state how much caffeine each participant had, or if they were particularly sensitive to the substance. They also noted that the study also included some African-American people, and cautioned that other racial or ethnic groups may have different results.
There was a strong link with cigarettes, however, and the impact that nicotine has on sleep patterns.
Another study also carried out by Harvard Medical School even said that a moderate amount of coffee (three to four cups a day) could be linked with a longer life span. While there are some health risks involved with caffeine intake, they also pointed out some health benefits to drinking coffee.
It said that people who drink coffee could have a reduced risk of cardiovascular disease (including heart attack, heart failure, and stroke), type 2 diabetes, Parkinson's disease, uterine and liver cancer, cirrhosis and gout.
According to the HSE, people should avoid caffeine - which is found in coffee, tea, fizzy drinks and energy drinks - after 2pm if they want to avoid a disrupted sleep.
Ireland is the second-most sleep-deprived country after the UK, according to a 2017 survey by Aviva.