The human immune system needs to learn how to spot dangerous infections - and scientists may now know which gene controls this.
Research revealed the role of the gene
The finding could help scientists find ways to make vaccines, which rely on a good immune response, more effective.
The gene is called SAP, and scientists had already linked problems with it to a rare and potentially fatal immune disorder called X-linked lymphoproliferative disease.
People with the condition lack the correct version of the gene.
We haven't seen a gene that does this before
Dr Rafi Ahmed, Emory Vaccine Research Center
Doctors noticed that many people with the disease die because they cannot gain long-term immunity against the Epstein-Barr virus, which is not normally a problem the first time you get it.
The researchers, from the Emory University Health Center in the US, found that mice created without the SAP gene reacted exactly the same way as normal mice when confronted with an infection.
The immune system sprung into action to mount a response against the virus - but, after the first response faded away, the mice without SAP did not produce the "memory B" immune cells that allow the system to "remember" the virus.
Next time the infection presented itself, the deficient mice would not be able to fight it as effectively, but would have to start from scratch.
Dr Shane Crotty, from the Vaccine Research Centre at Emory, said: "This gene is clearly important for immune responses.
"Our work now shows that the SAP gene is a central player in long-term antibody responses, and indicates that manipulation of SAP may have therapeutic benefits in generating better antibody responses."
Dr Rafi Ahmed, also from Emory, said: "What is so interesting about this gene is that it controls the generation of long-term memory, but it's not important for short-term immune responses.
"We haven't seen a gene that does this before."
The principles of immune memory are key to the success of vaccines.
In these, a tiny "dose" of the bacteria or virus that causes the disease is given, in a weakened form that can't make the patient ill.
The idea is that the body will "remember" the pathogen, and mount a better immune response next time it is confronted by it, thus preventing illness.
If the gene might offer a way to boost this memory, then vaccines might be made more efficient, or the chance of side-effects reduced.