Though most Shabbat observant Jews permit opening and closing a refrigerator during Shabbat, some authorities require that the door only be opened when the refrigerator motor is already running. Otherwise, the motor will be caused to go on sooner by the increase in temperature indirectly caused by the flow of heat from the outside. Most refrigerators and freezers automatically set the motor to turn on and blow cold air whenever the thermometer registers a temperature that is too high to keep the food cold. However, Rabbi Shlomo Zalman Auerbach and most authorities permit opening the door because this result is indirect, and because there are additional grounds to be lenient.
Additionally, any incandescent light which is triggered upon opening the door must be disconnected before Shabbat. It is not permitted to open the door if the light will turn on because, unlike with the motor running, the light turning on is a Biblical prohibition whereas the motor running may be a Rabbinic prohibition, and also, the light is turned on immediately as an effect of opening the refrigerator whereas the motor turning on is an indirect effect. [So says wikipedia.]