An aspirin a day could keep skin cancer away, according to a new report in the journal Cancer.

Researchers in Denmark and the U.S. found that people taking common painkillers like aspirin and ibuprofen were less likely to develop skin cancer — including squamous cell carcinoma and malignant melanoma — especially when they took the drugs for at least seven years or used them at least twice a week. It’s not the first study to show a potential anticancer effect of aspirin and other similar painkillers — a class of medications known and nonsteroidal anti-inflammatory drugs, or NSAIDs. Previous studies have found that aspirin users enjoyed a lower risk of colon cancer; a trial published earlier this year concluded that people who take a daily aspirin have as much as a 46% lower risk of colon, lung and prostate cancers, compared with non-users.

In the current trial, researchers looked at all cancer cases in the Danish Cancer Registry from 1991 to 2009 and compared this data against that of a prescription-drug database that recorded patients’ histories of using aspirin, NSAIDs or COX-2 inhibitors, drugs that all work in similar ways to reduce inflammation and dull pain.

Overall, 18,532 cases of skin cancer were included in the study. Each case was compared to 10 matched controls who did not develop the disease. Over the study period, people who filled more than two prescriptions for aspirin, NSAIDS or COX-2 inhibitors had a 13% lower risk of melanoma and a 15% lower risk of squamous cell carcinoma than those who filled fewer prescriptions, the researchers found.

The longer people took the drugs, and the higher the dose, the greater the anticancer benefit. Longer, higher-intensity use, for example, led to a 46% lower risk of melanoma, a 35% lower risk of squamous cell carcinoma and a 17% lower risk of basal cell carcinoma, the most common form of skin cancer in the U.S. The relationship held even after the researchers adjusted for potential confounders that could affect the risk of skin cancer, such as use of other medications. However, the researchers didn’t have information on other key skin cancer risk factors like exposure to UV radiation.

The drugs are thought to counter cancer growth by suppressing inflammatory pathways and stimulating tumors’ ability to expand and develop blood supplies.

“Given the high skin cancer incidence and the widespread and frequent use of NSAIDs, a preventive effect of these agents may have important public health implications,” the authors, led by Sigrun Alba Johannesdottir from Aarhus University Hospital in Denmark, wrote.

In the U.S., skin cancer is the most common form of cancer diagnosed, affecting more than 2 million people each year. But taking aspirin and aspirin-like drugs isn’t without consequences: they may have harmful side effects on the stomach and digestive tract, causing bleeding and dangerous ulcers. (One COX-2 inhibitor, Vioxx, was voluntarily pulled from the market by its maker in 2004 after it was linked to an increased risk of heart disease.)

But given the growing body of data linking aspirin use to lower cancer risk, the researchers say it may be worth factoring in the drugs’ anticancer effects when patients and doctors discuss options for pain relievers. “We hope that the potential cancer-protective effect of NSAIDs will inspire more research on skin cancer prevention,” Johannesdottir said in a statement. “Also, this potential cancer-protective effect should be taken into account when discussing benefits and harms of NSAID use.”

Alice Park is a writer at TIME. Find her on Twitter at @aliceparkny. You can also continue the discussion on TIME’s Facebook page and on Twitter at @TIME.