Etching---varying degrees of scratching or pitting of a glass surface---can occur for a variety of reasons. High temperatures, soft water, over- or incorrect-use of dishwasher detergent, inadequate rinsing and friction typically act as the primary culprits---dissolving glass and leaving it with a rainbow film, spotted, cloudy or frosted appearance. Although most glass pieces will etch microscopically with any type of washing over time, given that etching is permanent damage, treating the "potential causes" of severe dishwasher-related etching can help protect and preserve your glassware for years to come.
Lower your hot water heater and/or dishwasher temperature to below 60 degrees C as hot water accelerates etching.
Test your water's hardness level as naturally soft water, or water treated to break up various mineral deposits, can wear away glass.
Change the amount of detergent that you use to match the hardness level---typically, 1 tsp non-concentrated detergent per water hardness level with no less than 1 tbsp per load. Dishwashing detergents act as water softeners. They contain ingredients used to dissolve hard minerals in water. Using a water-softening agent in soft water, or these ingredients at levels higher than recommended for the level of minerals in the water, increases soft water erosion as the ingredients "act upon" or "react with" the glass dissolving it instead of the minerals the detergents were formulated to combat.
Put "dirty" glasses in the dishwasher. Formulated to break up and remove food and other debris from dishes, dishwasher detergents break down the only available surface---the glass itself---on pre-rinsed glasses.
Wash your glassware in smaller loads that allow more space between pieces for better rinsing as residue from detergents on dry glasses can continue to cause etching after washing.
Position your glassware in the dishwasher so that it doesn't bump, rub or otherwise create friction with any other glass pieces or dishes as the friction can etch glass.
Hand-dry your glassware using a soft lint-free microfiber cloth (textured or non-textured) after the rinse cycle to remove any leftover residues or use a specially formulated rinse-aid such as Cascade Crystal Clear or Jet-Dry that promotes better rinsing, including removal of alkaline detergent residue, and rapid, spot-free drying.
If using concentrated detergent, halve the measurements in Step 3.
Never put antique, fine, crystal or handblown glass pieces in a dishwasher as hot water and/or detergents can not only etch these pieces, but also remove hand painted trim or images and/or break the glass. Instead, wash the pieces by hand in a mild dish detergent, rinse completely and dry with a lint-free microfiber cloth.