Cancer vaccines work by targeting specific antigens present on the surface of cancer cells. These antigens are recognized by the immune system as foreign, prompting an immune response. There are two main types of cancer vaccines: preventive and therapeutic. Preventive vaccines, such as the HPV vaccine, aim to prevent cancer by protecting against viruses that can cause cancer. Therapeutic vaccines, on the other hand, are designed to treat existing cancer by boosting the body's immune response against it.