Avoid caffeine which can increase bladder spasms. Drink plenty of cranberry juice. It can be very helpful in preventing and treating a urinary tract infection. It works by preventing bacteria from sticking to the walls of the bladder where it can multiply and cause infection.