Summarize this article:

OTC H2RAs work by reducing the production of stomach acid, which in turn makes heartburn less likely. They often work best when taken about 30 minutes before your main meal of the day, but follow the package instructions or your doctor's recommendation. OTC brand names include Pepcid, Zantac, and Tagamet. Even though these are OTC medications, they can cause serious side effects or drug interactions. Talk to the pharmacist or your doctor before using an H2RA. H2RAs are typically meant to be taken once per day for up to 14 days. Talk to your doctor if you believe you need to use the medication for a longer term. Like H2RAs, PPIs reduce stomach acid production, but they do so through a different process. Therefore, some people have better results with a PPI. Like H2RAs, PPIs usually work best when taken about 30 minutes before your largest daily meal. As with H2RAs, follow the package directions or your doctor's instructions. And check with your doctor or pharmacist regarding potential side effects or drug interactions before starting on a PPI. Don't use a PPI for more than 14 consecutive days without your doctor's guidance. OTC brand names include Prilosec, Protonix, and Nexium. Antacids like milk of magnesia (magnesium hydroxide) and calcium carbonate (e.g., Tums, Rolaids) can help to reduce and neutralize stomach acid when you are experiencing heartburn. They cannot, however, help prevent heartburn from occurring in the first place. Antacids come in many brands, and in liquids, chewables, powders, and other forms. They all work in roughly the same manner, however. As with any OTC medication, you should check with your doctor or pharmacist before using antacids, especially if you take other medications or have underlying medical conditions. If you have frequent heartburn (more than twice per week) or less-frequent but severe instances of heartburn, you may have gastroesophageal reflux disease (GERD). Whether you have GERD or just recurring heartburn, however, you should visit your doctor for a proper diagnosis and treatment options. Your doctor may prescribe a prescription version of a PPI or H2RA medication for daily use. Make sure you follow your doctor's instructions for taking it. They may also be able to provide advice on dietary and lifestyle changes.
Try an over-the-counter (OTC) H2 receptor agonist (H2RA) medication. Use an OTC proton pump inhibitor (PPI) medication as another option. Use antacids to relieve, but not prevent, heartburn. Talk to your doctor about prescription medications.