An optical technique for constant-height mode scanning force microscopy has been developed. This approach allows the sample-tip spacing to be held constant or varied in a quantitative manner during data acquisition. The technique uses an all-fiber interferometric system extended to include two optical cavities: one between the fiber and the cantilever and a second between the fiber and the sample surface. It is necessary that the cantilever be semitransparent or that the fiber be positioned over the edge of the cantilever. It has been experimentally verified that either case allows sufficient laser light for both the cantilever-fiber and the sample-fiber cavities. This method can be used to monitor the time dependence of surface forces, magnetic or electric phase transitions, or as a height calibration for use with scanning force microscopy. As a demonstration of the technique, spatially localized observations of the ferromagnetic phase transition in a gadolinium film are presented. During this observed phase transition, the tip-sample separation was held constant at 1000 nm with a drift of only 3 nm, nominal, for 15 min while the temperature was cycled between 285 and 295 K.