A role for caffeine
Since the statistically significant inverse association between coffee consumption and development of symptomatic gallstones (or gallbladder disease) is observed for regular caffeinated coffee only, and not for decaffeinated coffee5,6, this would strongly suggest that caffeine has a beneficial effect on the development of the disease.
Other components
On the other hand, a small trial10 showed that consumption of 165ml (or one large cup) of a standard coffee brew raised plasma cholecystokinin* levels and triggered gallbladder contraction. These effects occurred for both regular and decaffeinated coffee10. For decaffeinated coffee, the effect tended to be slightly smaller but not statistically different from regular coffee. This would suggest that coffee components other than caffeine are likely to play a role.
It may be that, in the early stages of the disease, coffee and caffeine prevent or delay the development of gallstones, or delay symptoms. In this instance, gallbladder contractions are likely to be beneficial. However, in cases where symptomatic gallstones have developed, further coffee and caffeine-triggered gallbladder contractions might lead to more severe symptoms.
Indeed, the differences observed in the associations between coffee consumption and previously undiagnosed (~non-symptomatic) versus previously diagnosed (~symptomatic) gallbladder disease9 are suggestive of a dual role for coffee and caffeine. In other words, people with symptomatic gallstones may reduce their coffee consumption as a result of their symptoms, rather than develop more severe symptoms because of a reduction in coffee consumption.