Allergic reactions to a component of the immune system may also help protect skin against cancer, according to a study.