Vaccines like those for smallpox provides long-term immunity whereas the ones for typhoid provides short-term immunity.
In long term immunity, the memory cells in the immune system can generate antibodies for long periods.
Whereas in short-term immunity, the memory cells can generate antibodies only for short-periods. Later, these cells lose their memory.