It found those who took caffeine tablets, rather than dummy pills, fared better on the memory tests.

But experts warned people to remember caffeine could cause negative effects, such as jitteriness and anxiety.

The Johns Hopkins University study involved people who did not regularly eat or drink caffeinated products.

Saliva samples were taken, to check base levels of caffeine, then participants were asked to look at a series of images.

Five minutes later they were given either a 200-milligram caffeine tablet - equivalent to the caffeine in a large cup of coffee, according to the researchers - or a dummy pill.

Saliva samples were taken again one, three and 24 hours later.

The next day, both groups were also tested on their ability to recognise the previous day's images.

Altered images

Twenty-four hours may not sound like a long time, but it is in terms of memory studies. Most "forgetting" happens in the first few hours after learning something.

People were purposely shown a mixture of some of the initial tranche of images, some new - and some that were subtly different.

Being able to distinguish between similar, but not identical items, is called pattern separation and indicates a deeper level of memory retention.

More members of the caffeine group were able to correctly identify "similar" images, rather than wrongly saying they were the same.

Our study suggests that 200mg of coffee is beneficial to those who do not regularly ingest caffeineProf Michael Yassa, Johns Hopkins University

Prof Michael Yassa, who led the study, said: "If we used a standard recognition memory task without these tricky similar items, we would have found no effect of caffeine.

"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."

Only a few previous studies have been carried out into caffeine's effect on long-term memory, and those that have been done generally found little effect.

This study was different because people took the caffeine after, rather than before, they had seen and attempted to memorise the images.

The team now want to look at what happens in the hippocampus, the "memory centre" of the brain, so they can understand caffeine's effect.

Moderation

But Prof Yassa said their findings do not mean people should rush out and drink lots of coffee, eat lots of chocolate - or take lots of caffeine pills.

"Everything in moderation. Our study suggests that 200mg of coffee is beneficial to those who do not regularly ingest caffeine.

"But we also show an inverted U-shape dose response suggesting that higher doses may not be as beneficial.

If you take too much caffeine there could be negative consequences for the bodyDr Ashok Jansari, University of East London

"Keep in mind that if you're a regular caffeine drinker this amount may change."

He added: "There are of course health risks to be aware of.

"Caffeine can have side effects like jitteriness and anxiety in some people. The benefits have to be weighed against the risks."

Dr Anders Sandberg from the Future of Humanity Institute at the University of Oxford, said: "The paper demonstrates that giving caffeine after seeing images does improve recognition of them 24 hours later, supporting the idea that it helps the brain consolidate the learning.

"However, there was no straight improvement in recognition memory thanks to caffeine. Rather, the effect was a small improvement in the ability to distinguish new images that looked like old, from the real old images."

He added: "Caffeine may still be helpful for paying attention to what you are studying and hence help your encoding, but the best way of boosting consolidation is sleep - which might be a problem in this case, if you take the caffeine too close to bedtime.

Dr Ashok Jansari, from the University of East London's school of psychology, said caffeine appeared to "sharpen" memory, rather than actually making it better.

He said: "I would definitely not advise that people start taking in as much caffeine as possible since in terms of memory anything above 200mg may not help much and if you take too much caffeine there could be negative consequences for the body."