Cancer vaccines typically depend on cumbersome and expensive manipulation of cells in the laboratory, and subsequent cell transplantation leads to poor lymph-node homing and limited efficacy. We propose that materials mimicking key aspects of bacterial infection may instead be used to directly control immune-cell trafficking and activation in the body. It is demonstrated that polymers can be designed to first release a cytokine to recruit and house host dendritic cells, and subsequently present cancer antigens and danger signals to activate the resident dendritic cells and markedly enhance their homing to lymph nodes. Specific and protective anti-tumour immunity was generated with these materials, as 90% survival was achieved in animals that otherwise die from cancer within 25 days. These materials show promise as cancer vaccines, and more broadly suggest that polymers may be designed to program and control the trafficking of a variety of cell types in the body.