For years, women have been passing along the secret to treating and preventing urinary tract infections, or UTIs: cranberries. But research has been mixed as to whether cranberries, their juice or cranberry capsules really help.

An October 2016 study published in the Journal of the American Medical Association found that female patients in nursing homes who took cranberry capsules for a year didn't have fewer episodes of UTIs than those who took placebos.

In an editorial also in JAMA, Dr. Lindsay E. Nicolle, an expert on UTIs at the University of Manitoba, wrote that the study evidence is “convincing that cranberry products should not be recommended as a medical intervention for the prevention of UTI.” She added that “clinicians should not be promoting cranberry use by suggesting that there is proven, or even possible, benefit.”

She concluded, “It is time to move on from cranberries.”

However, earlier studies have shown a more positive link between the small red berries and UTI prevention or treatment.

For example, a July 2012 study found that cranberries can lower the chance of repeated infections in young women. It found that cranberry consumption in some instances can cut the risk of recurrent UTIs by as much as 47 percent.

The study, published in the Archives of Internal Medicine, was conducted by researchers from National Taiwan University Hospital. The team looked at 13 studies in which participants, mostly women, were asked to consume cranberry products or a cranberry-free placebo for the course of the trial. Most of the studies lasted six months.

Researchers found that those who regularly drink cranberry juice or take cranberry capsules are less likely to get urinary tract infections. Cranberry consumption was particularly helpful for women who had trouble with recurrent UTIs.

Overall, the study participants who consumed cranberry products on a daily basis had 38 percent fewer UTIs than those who took a placebo. Women who had a history of recurrent UTIs, reduced their risk of future infections by 47 percent while taking cranberry products.

Why do cranberries have the potential to fight UTIs? The studies suggest that certain compounds in cranberries might prevent bacteria from attaching to tissue in the urinary tract, thereby preventing infection.

Unsure whether to turn to cranberries to prevent and treat UTIs? Talk to your doctor. Antibiotics are the recommended method of treatment, reports the Mayo Clinic. When it comes to prevention, drinking cranberry juice can't hurt. You may also want to try drinking plenty of fluids, emptying your bladder right after intercourse, avoiding potentially irritating feminine products, and always wiping from front to back when you go to the bathroom.

Editor's note: This story was originally published in July 2012 and has been updated.