A double espresso after revision might be the best way of preparing for an exam, new research suggests.
Scientists have found the first clear evidence of caffeine's memory-boosting effect, and shown that it lasts for at least 24 hours.
Volunteers took part in a double-blind trial in which they were either given a 200mg caffeine pill or a placebo five minutes after studying a series of images.
Tests a day later proved that the memory of those who took caffeine had been enhanced at a deep level. The amount of caffeine used was roughly equivalent to a double shot of strong espresso coffee.
US lead researcher Dr Michael Yassa, assistant professor of psychological and brain sciences at Johns Hopkins University, Baltimore, said: "We've always known that caffeine has cognitive-enhancing effects, but its particular effects on strengthening memories and making them resistant to forgetting has never been examined in detail in humans.
"We report for the first time a specific effect of caffeine on reducing forgetting over 24 hours."
More than 100 participants took part in the study, none of whom were regular users of caffeinated products.
Before being given the caffeine or placebo, they were asked to identify a series of pictured objects as either outdoor or indoor items.
The next day, both groups were tested on their ability to recognise the images they had been shown earlier. Some of the images were the same as the ones they had seen, some were new, and some similar but not identical.
Although all the volunteers correctly identified "new" and "old" pictures, those who had taken the caffeine pill were better able to spot "similar" images.
Participants not dosed with caffeine were more likely to be fooled into thinking the similar pictures were the ones viewed the previous day.
Recognising the difference between two similar but not identical items reflects a deep level of memory retention, the researchers reported in the journal Nature Neuroscience.
"If we used a standard recognition memory task without these tricky similar items, we would have found no effect of caffeine," said Dr Yassa. "However, using these items requires the brain to make a more difficult discrimination - what we call pattern separation, which seems to be the process that is enhanced by caffeine in our case."
He added: "Almost all prior studies administered caffeine before the study session, so if there is an enhancement, it's not clear if it's due to caffeine's effects on attention, vigilance, focus or other factors.
"By administering caffeine after the experiment, we rule out all of these effects and make sure that if there is an enhancement, it's due to memory and nothing else."