Immunity from infection or vaccines - which lasts longer?

While some level of immunity is essential to fight off future infectionss, is one more effective than the other? We compare

Immunity from infection or vaccines - which lasts longer?
While some level of immunity is essential to fight off future infectionss, is one more effective than the other? We compare