There has been a lot of discussion about whether people who have COVID-19 and recover will have long-lasting immunity. At the same time, work is underway to create a vaccine for this disease. But if infection does not necessarily provide immunity, can a vaccine still do it? Are there known diseases for which a vaccine provides durable immunity even when infection does not?
I did find one page that says in passing that "it is true that natural infection almost always causes better immunity than vaccines", but I wasn't able to find anything more detailed about the two types of immunity.