The first step to replacing a fuel cap is to get the right fuel cap. Find out the make, model and sub-model. Your car manual can assist you to find the specs for the fuel tank cap and its gasket.
You should not try to substitute the cap with another model even if it looks similar. After acquiring the suitable fuel cap, locate the cause of the problem. In case the fuel tank cap has ventilation issues, you can fix your old cap. Observe whether the gas cap has a cap retention ring to keep it from dropping off. In case it does, examine how it is connected to the car. Also observe any dirt or corrosion. Open the parts and clean them with lacquer thinner to get rid of the residue.
Allow the parts to dry after cleaning. Reassemble the inside part of the cap, and insert the top and bottom parts. To properly lay the O-rings, keep the pressure on the lower part when rolling its edges over the top. If the gasket is cut, squeezed or damaged, you need to replace it. Since the old gasket becomes hard with time, regular greasing is important. Place the cap on the fuel tank and twist it in a clockwise motion. Move it until it clicks three times.