Dairy is not one group where shelf life is concerned: products lasting a few days sit on the same shelf as products lasting months. The first variable is heat treatment. In pasteurised products some organisms survive and life depends on the cold chain; in long-life products the heat treatment is more severe and, unopened, the product keeps at room temperature.

ProductWhat sets its lifeIf temperature slips
Pasteurised milkA steady cold temperature is assumedA few hours of warming leave less life than the label states
Yoghurt and fermented productsAcidityFermentation continues and the product turns sour; a quality limit
Fresh cheeseHigh moistureDepends entirely on the cold chain
Matured cheeseLow moistureThe rate of ripening changes

The type of date on the label also follows the product. For food that is highly perishable from a microbiological point of view and could soon endanger health, a use-by date applies; in the EU food is deemed unsafe after it (Regulation 1169/2011, Article 24). For other products the best-before date is about quality.

Light is a loss of life independent of temperature. In a Virginia Tech study, 2% milk in glass and translucent HDPE bottles oxidised within four hours under LED lighting of 1068 lx.

If life comes in shorter than expected, measure three places in order: cooling speed after filling, peak temperatures in distribution and the retail cabinet. Changing the formulation before measuring those three is usually looking in the wrong place.