You are absolutely correct that there are links between certain foods and certain types of cancers. When it comes to stomach cancers and heartburn, there are two important things to consider. First, while heartburn can be a bothersome complaint for many people, there are some individuals who have significant and continued acid reflux
into their esophagus if the sphincter--sort of like a valve--between the stomach and the esophagus is not tight enough to prevent food from refluxing out with meals. Over time, the effects of the acid on the esophagus can lead to changes in the esophageal lining that can develop into esophageal cancer. Controlling acid reflux is thus very important for people who have severe symptoms.
Second, the lining of the stomach can also be affected by certain types of foods and chemicals. In particular, smoked or preserved foods (especially those preserved with compounds called nitrates) have been very strongly linked to stomach cancer. Countries where these foods are routinely eaten have the highest rates of stomach cancer. In addition, alcohol consumption is also associated with higher rates of stomach cancer. In contrast, diets rich in fruits and vegetables (and their anti-oxidant vitamins) is associated with decreasing cancer risk.
If you are concerned about your cancer risk, the best thing to do is discuss these concerns with your primary care physician