For many of us, remembering faces from 30 years ago can be something of a challenge. But cells in our immune system can remember old foes just fine, and we've never really been sure exactly how they manage it.

A new study has filled in missing details on the steps our body takes to remember pathogens, finally revealing the steps our immune cells take to preserve a reference library of past battles.

Scientists from the University of California, Berkeley, used a hydrogen isotope to label white blood cells inside volunteers, and tracked a specially selected virus from infection to immunity in order to record significant steps in the immune process.

The big picture of adaptive immunity and our ability to remember and eliminate specific pathogens has gradually built up over the past century.

We have different types of white blood cell that help spot and destroy invading cells. Two of these are B cells, which make and secrete antibodies to act as 'name tags' for the bad guys, and T cells, which perform a bunch of immune-related tasks such as recognising the foreign invaders.

Both include cell types that act as cellular historians, preserving remnants of past battles like old veterans.

Exactly how our immune cells do their job of identifying and then recording these events – at least on a chemical level – is where the story gets vague.

"This work addressed fundamental questions about the origin and longevity of human memory CD8+ T cells generated after an acute infection," says senior author and nutritionist Marc Hellerstein from UC Berkeley.

Cytotoxic 'CD8+' T cells are a form of cellular assassin, raised in the body's thymus to recognise familiar cells before being released to find unfamiliar fiends - such as cancer cells, bacteria, or cells infected with viruses.

On finding them, the body encourages these special T cells to proliferate. The small army releases chemicals into the enemy cells, punching holes in their membranes and destroying them.

Not all cytotoxic T cells go into battle to die glorious deaths taking down the enemy, though. Some stick around, and appear to be responsible for mounting quicker attacks should the tumours or pathogens return.

To get to the bottom of this process, the researchers gave 40 volunteers water that contained deuterium instead of standard hydrogen, which marked out any new cells they produced in their body at different intervals.

They then vaccinated them with an attenuated live yellow fever vaccine – a virus that the volunteers shouldn't encounter in their home environment.

With the new CD8+ T cells readily identifiable, the researchers were able to track the cells over coming months to gain an idea of how their numbers and chemical make-up changed.

They discovered that after the initial response to the vaccination, a pool of memory cells forms. These cells look and behave more like naive cytotoxic T cells, with one difference; their genes are tagged epigenetically with the memories of war.

"These cells are like veteran soldiers, camped in the blood and tissues where they fight their battles, waiting for yellow fever to show up," says Hellerstein.

"They are resting quietly and they wear the clothes of untested new recruits, but they are deeply experienced, ready to spring into action and primed to expand wildly and attack aggressively if invaders return."

This quiescent state is the secret to their success, allowing them to quietly lurk in the background, ready to shift into high gear and attack the moment the pathogen returns.

On average, T cells have a half-life of about 30 days, meaning after a month most of the white cells have died. These disguised veteran T cells have a half-life of 450 days, meaning some of them can stick around for years, if not decades.

And the more we know about the memory system of our immune cells, the better we can use it to our advantage.

"Understanding the basis of effective long-term immune memory may help scientists develop better vaccines, understand differences among diseases and diagnose the quality of an individual person's immune responses," says Hellerstein.

This research was published in Nature.