Yeast Infection

I keep getting these horrible yeast infections!! at least once every 3 or 4 months. they’re so painful and last about a week. my boyfriend gets them too but we can’t figure out why. any tips on why they’re so frequent or if they could be caused by sex??