Researchers say your first flu infection in childhood can provide protection against similar flu viruses for the rest of your life.

If you have ever had the flu and been stuck in bed for days, you may have wondered why some people around you who got sick were barely affected.

New research suggests that the year you were born plays a big part in this.

Or more specifically, the type of virus you were first exposed to as a child predicts which ones you will be vulnerable to later in life.

On the flip side, you may also have a better chance of fighting off an infection caused by a flu virus similar to the one you were exposed to in childhood.

Read more: Get the facts on flu symptoms »

In the study, published today in Science, researchers focused on two recent types of avian flu, H5N1 and H7N9.

These circulate in animals but don’t occur commonly in people. Only around 1,500 known human cases were caused by these two viruses, mostly in Asia and the Middle East.

Researchers found that people infected with these viruses fell into two groups — based on when they were born.

The shift occurred in 1968 with the Hong Kong flu pandemic, when a new type of virus swept away the virus that had dominated before.

People born before 1968 had likely been exposed as children to a flu virus that scientists place into “group 1.”

Researchers found that as adults, these people were less likely to become severely ill or die from H5N1, which is also in group 1. But they were more likely to get sick from H7N9, a “group 2” flu virus.

People born after 1968 were likely exposed to a group 2 virus. They showed the reverse trend — less susceptible to H7N9, and more vulnerable to H5N1.

“Our findings show clearly that this ‘childhood imprinting’ gives strong protection against severe infection or death from two major strains of avian influenza,” study author James Lloyd-Smith, Ph.D., a professor of ecology and evolutionary biology at the University of California Los Angeles, said in a press release.

The flu cases that the researchers looked at, though, were only the most severe — where people were sick enough to end up at the doctor’s office or in the hospital.

“The authors focused on the incidence of severe influenza, and it is not completely clear whether the patterns of severe infections are similar to the patterns of mild infections — or all infections,” Ben Cowling, Ph.D., a professor of infectious disease epidemiology at The University of Hong Kong, who was not part of the study, told Healthline.

Differences in how people are exposed to the two avian flu viruses might also impact which people get sick.

“Relatively few people have been exposed to H5N1 in live poultry markets, apart from occupational exposure in the workers there,” said Cowling, “while exposure to H7N9 has probably been widespread in the workers and the customers.”

Read more: Get the facts on this year’s flu vaccine »

Even though H5N1 and H7N9 are found mainly in animals, scientists are concerned that the viruses could adapt to spread more easily between people.

If that happens, it could trigger a flu pandemic.

This research could help health officials estimate the potential risks of a new worldwide flu outbreak.

“When a new virus emerges with pandemic potential, we can consider which group it is in, in order to predict what the age pattern of infections might be like,” said Cowling.

Researchers say that much of the information needed to make these risk assessments is already collected by governments and public health agencies.

“It turns out we can learn a lot about flu pandemic risk from information about humans, which we’ve already got,” said Lloyd-Smith.

This approach gets a little tricky when looking at people born after 1977, when both group 1 and group 2 viruses were in circulation.

As far as scientists know, people can only develop childhood imprinting against one flu virus group — an effect that lasts for life.

Read more: Recommendations on this year’s flu »

Researchers say that childhood imprinting depends upon hemagglutinin, a receptor protein that sticks out from the surface of the flu virus.

Differences in this protein give rise to the two virus groups.

When a person is first exposed to the flu virus, the immune system makes antibodies for this receptor. Those antibodies stick around throughout a person’s life, providing protection against other flu viruses in that group.

Researchers think that a similar process explains why so many young people died during the “Spanish” flu pandemic of 1918-1919. Nearly half of the 50 million people worldwide who died were between 20 and 40 years old.

A group 1 virus caused the Spanish flu, while young people were likely exposed to a group 2 flu virus as children — leaving them especially vulnerable in 1918.

More research is needed to understand exactly how imprinting works in the face of both shifting flu types around the world and our attempts to stay one step ahead.

“This work also inspires further examination of immunity to influenza infections and disease,” said Cowling, “particularly following repeated re-infections or vaccinations through life, an area which is still not fully understood.”