Natural infections almost always yield a better immunity than that acquired through vaccination. However, vaccines yield a better immune-response than getting infected with influenza. That is so to say the side effects.
I want to backtrack to part of your questions where you say
I'm sure the immune system will "remember" that particular strain just as well as getting a vaccine. and add a little bit of interesting information regarding influenza.
Some Influenza (A) stereotypes that infect humans are: H1N1, H2N2, H5N1, etc...
The H stands for Hemagglutinin and N is Neuraminidase. These are important in vaccine development. The H and N are proteins located on the surface of the virus and allow for entry into a cell for infection.
Strains are classified according to their hemagluttinins and neuraminidases. Every year when the vaccine for the seasonal flu is developed we don't know with 100% certainty which strain might be the most prevalent. Rather, surveillance data is used in deciding which flu might be the most prevalent. More info on the CDC Website.
So back to the question:
Does the immune system remember that particular strain just as well as
getting a vaccine?
Yes it does and there's a paper in PNAS that looked at something similar. This is related to something called “Immunological Honeymoon”. A theory that the first infection during childhood provides stronger immunological memory than a later infection.
The paper found that people who were 28 year old were more susceptible to the Spanish Flu (H1N1) in 1918 because they had been exposed to the wrong virus as children.
The elderly, however, had been exposed to H1N1 as children and were well protected. People who were middle aged or in their teens in 1918 had been exposed to H1N8 as children and were partially protected.
This I recon is just as good as vaccine, but more to show that the immunity acquired through infection is, in fact, remembered. For how long? That's a totally different question that varies from infection to infection. Some are life-long (such as measles), other are short lived requiring re-infection, or booster shoots in case of vaccination.