The prostate specific antigen (PSA) test is used to diagnose possible prostate problems, including cancer, enlarged prostate, and inflammed prostate. There is no need for fasting before a PSA test. The doctor may tell you to avoid any sexual activity for a few days before hand, as ejaculation can temporarily raise PSA levels, and to avoid physical activity for a few days before as well, as this too may raise levels. Eating before the test will not affect it.
As an aside, do note that PSA tests are not a perfect test, and will not always indicate cancer. If you have an enlarged prostate (benign prostatic hyperplasia) or an inflammed prostate (prostatitis), this can also affect your PSA test. In addition, PSA naturally rises over time as you get older, from 2.5 ng/mL when you are young to 8 and above when you reach your 70s and 80s.