To minimize attacks, a sufferer may benefit from avoiding certain foods that stimulate excess acid secretion and/or relax the opening between the stomach and esophagus. Acid fruit or juice, fatty foods, pretzels, coffee, tea, onions, peppermint, chocolate, or highly spiced foods are to be avoided, especially shortly before bedtime.
When I get heartburn I'm always told to either drink milk or eat cucumber, lol. So you could also do things to get rid of it faster whenever it does happen as well, also other things, like sitting up straight etc.