The USDA has this to say on it:
Storing Leftovers
One of the most common causes of foodborne illness is improper cooling of cooked foods. Because bacteria are everywhere, even after food is cooked to a safe internal temperature, they can be reintroduced to the food and then reproduce. For this reason leftovers must be put in shallow containers for quick cooling and refrigerated within 2 hours.
You'll find similar statements from government agencies around the world. The safe limit for raw or cooked food is 2 hours in the danger zone (40-140° F or 4.4-60° C).
If you're a restaurant owner or cook, you must follow this rule, hold hot foods above 60° C and quick-cool other foods before refrigerating. If you are not working in a professional capacity then you are not legally required to follow it, but if you are serving guests then it would be irresponsible (and possibly actionable, if someone gets sick) to do otherwise.
If you're an individual serving only yourself, then take whatever liberties and break whatever rules you want; it's your food, and your body. But there's no table or chart anyone can give you; there's no single specific point at which a food transitions from "not entirely safe" to "probably will kill you" because it depends entirely on the food, the environment, your immune system, and a plethora of other variables. The rule is 2 hours, period; any longer and there is some non-trivial risk to your health.
Some hints, tips, and warnings:
The 2-hour rule is a conservative estimate with a safety margin. Don't ask what that margin is. It's like asking what the "real" speed limit is on a posted road; you might know from experience, but it could change depending on circumstances and exceeding it by any amount means you take your chances and accept the risks.
Don't put large, hot items (such as an entire pot of soup or chili) directly into the fridge. The residual heat will warm up and potentially spoil other items in the refrigerator.
To quickly cool large cooked items, use an ice-water bath and/or divide them into small containers. (Note: Don't use an ice-water bath for cast iron.)
Don't assume that re-cooking an improperly-stored item will make it safe. Most bacteria produce protein toxins, which are actually the primary agents responsible for food poisoning, and several of these toxins are heat-resistant. Cooking will not kill or inactivate these toxins and eating the re-cooked food will still make you sick.
Don't assume that cooking "kills everything" and that a cooked food or cooking surface is absolutely sterile. Cooking kills enough to make the food safe to eat, but some organisms - such as bacterial spores from bacillus and clostridium - can survive the cooking process and immediately start producing more bacteria. Sous-vide bags, crock pots, etc. are not safe environments for cooked food in the temperature danger zone.
In the answer linked in the question, I already provided the results of a simple experiment I carried out a few years ago with an infrared thermometer. However, tonight I decided to try something slightly better with something closer to a worst-case scenario. I don't think it definitively answers the question, but it gives another few data points.
I heated 4 quarts of water in a 6-quart stainless pot (with a glass lid) to a rolling boil. I chose water since I didn't want to risk spoiling a large quantity of food. Also, in some ways, water is a worst-case scenario. It doesn't hold as much heat as, say, the equivalent volume of chili, but the heat circulates better in a thin liquid. That means that the entire pot will stay at roughly the same hot temperature as it cools, rather than developing a cooler outer layer (as in a pot of chili), which will start to transfer heat more slowly after the initial burst.
Meanwhile, I inserted a digital probe thermometer with a cable to the display (usually for measuring meat temps in an oven) into a quart container of yogurt. The probe was stuck through the seal in the top of the container, so very little air should have been able to get in or out. The probe measures temperatures down to 32F accurately. I taped the probe in position so the tip was immersed in the yogurt about 1/8 inch in from the edge of the container.
At the start of the experiment, the temperature of the yogurt was 38F. Using an infrared thermometer, I could measure surface temps of many other items in the fridge, which varied from about 33F to 40F. (There were a couple outliers, due to inaccuracies about the way infrared thermometers deal with reflective surfaces.)
When the water was boiling, I measured the temperature with a separate probe thermometer: it registered 212F. I quickly put the lid on the pot and whisked it immediately into the fridge and shut the door.
The yogurt was less than 2 inches from the pot. I allowed just enough room for a reasonable amount of air circulation. The yogurt was oriented with the temperature probe toward the hot pot, so it should measure the area of the yogurt that would rise in temperature the most. Also, as noted, the probe was only a fraction of an inch from the edge of the container, so any fluctuations even near the surface of the food should be registered.
Approximate times of temperature change in the yogurt are noted here:
- 0 minutes: 38F
- ~13.5 minutes: 39F
- ~26.5 minutes: 40F
- ~44.0 minutes: 41F
- ~64.5 minutes: 42F
- ~125 minutes: 41F
I was only checking the temperature every 10 minutes or so near the end, so the timing of the move back down to 41F may be slightly off. At 150 minutes (2.5 hours), I stopped the experiment and removed the pot from the fridge, since I didn't want to waste any more time or energy cooling down a large pot of water.
Since little was happening with the temperature of the yogurt, I did open the fridge at 30 minutes to look around. Using an infrared thermometer, I could tell that some container surfaces on the same shelf as the hot pot had reached the upper 40s with a maximum of about 50F. (This included a dark surface container that is gray and black; it was not significantly different in temperature from the surface of the light-colored yogurt container.) However, a probe inserted into these containers showed that no food inside was above 40F after 30 minutes. Note that one large plastic container on that shelf had a large empty space near the top, and the surface temp for the empty portion rose to about 60-65F, but the bottom of container that actually contained juice remained about 40F, just like the yogurt.
Using the infrared thermometer, I measured the surface temperatures of food on shelves above and below the pot -- they barely budged a degree. Nothing on any shelves above or below the pot was above 40F. I checked these again every 30 minutes or so, with the same results.
(Note that 40F is not a hard cut-off point for bacterial growth. Many types of spoilage bacteria grow in the 32-40F range, and they merely grow incrementally faster as the temperature gets warmer above 40F. Spending an hour or two at 41F or 42F or even 45F is unlikely to cause problems -- this is a typical temperature range for most items kept on refrigerator doors -- though to be absolutely safe, avoid putting highly perishable items such as raw meats in areas with temperature fluctuations.)
I could feel warmer air circulating around the pot when the door was open, but it does not seem to have been enough to significantly alter temperatures other than in the items on the same shelf -- and there only by 2-4 degrees.
I also did check the water temperature a few times:
- 0 minutes: 212F
- 60 minutes: 156F
- 120 minutes: 128F
- 150 minutes: 116F
Since the temperature of the yogurt began to drop a little after 2 hours, it seems that even a gallon of water at about 130F wasn't enough to sustain a temperature increase in the fridge -- even on immediately adjacent items on the same shelf.
So, what do I conclude from this experiment?
Even a very large quantity of very hot food (a gallon of boiling water) was only able to move adjacent food items by a few degrees, and even that only might occur in outer layers of the food. Items on shelves above or below were barely impacted at all.
I would note that I did not place any food directly in contact with the hot pot, because that would obviously cause an unacceptable rise in temperature (the pot continued to feel quite hot to the touch even after a couple of hours). But with only a couple inches of space around the pot, the adjacent foods did not rise significantly in temperature.
I should also emphasize that surface temperatures of containers did rise up to 10-12 degrees on adjacent items in that first hour, even if the interior of the food varied much less. (By about 1-1.5 hours, the surface temps had settled back down to within a degree of the internal food temps.) I think this observation suggests that caution should be applied to keep highly perishable foods (e.g., uncooked meats) away from any very hot containers, though this seems like common sense.
Perhaps the most surprising result from my perspective is that the temperature rise was halted by the time the water temperature got down to maybe 140F or so. I doubt many people are placing foods a lot hotter than 140F directly in the fridge. Also, from a food safety perspective, the food could be cooled outside to 140F (which is when bacteria may begin to grow again), and then placed in the fridge for the rest of the cooling. In my fridge, anyway, it seems doubtful that even a relatively large quantity of food 140F or lower would cause things to heat up around it.
Again -- please note that I am NOT advocating this practice, since the hot food itself could take quite a few hours to cool down in the fridge, potentially causing spoilage in the hot food. (For large quantities, use an ice bath, or break down into small containers and allow plenty of air circulation in the fridge.) But, except in extreme circumstances, there should only be a minor impact on the rest of the food in a modern well-functioning fridge.
In any case, putting hot food directly in the fridge is a safer option than leaving it on the counter to cool.
Best Answer
In terms of food safety you can leave the door open for the same amount of time that your food can safely sit on the counter when taken out of the fridge. This is a couple of hours for most potentially hazardous foods as indicated in the answer to the linked question. This a cumulative time, so if you leave the door open for an hour three days in a row you're going to have to throw out a lot of food.
Of course this isn't really what you meant. If you're just leaving the door open while you pour yourself a glass of milk, the temperature of the food in the fridge isn't likely to reach the danger zone. How long that takes will depend on factors like the nature of the food and its location in the fridge, but I wouldn't worry about if you unless have it open for more than minute or so.
So from a food safety perspective you don't have to worry too much about leaving the door open. From an energy savings perspective you do however want to keep the length of time of the door is open to the minimum. The temperature of the air in the fridge will rise faster than temperature of the food, so every second you have the door open the fridge has do that much more work to cool it down again. This is probably the real reason why your parents told you to close the door immediately.