How long can I store a food in the pantry, refrigerator, or freezer?
General comments on the shelf-, fridge-, and freezer-life of foods
The shelf-life is the amount of time a food can be stored before it is considered unsuitable for use. It may be unsuitable due to quality degradation (no longer tasty) or food safety (risk of food poisoning). [1]
As far as food safety goes, food stored frozen at 0°F (-18°C) or below is remains safe forever; only quality degrades over time. [2]. Thus the freezer-storage times below are entirely about quality. This temperature should be maintained fairly closely (within 3°C[6] or 5°F) and a defrost / no-frost freezer should not heat air surrounding the products by enough to heat the products more than that.
If your freezer is set at a temperature higher than -18°C (three-star setting), these times may not apply. Especially the safe storage time in one-star freezers (-6°C) is much reduced.
The times all assume proper storage. Freezers 0°F or below, refrigerators 40°F (4°C) or below. [3] Cans should be stored in a cool, dry place, below 85°F (30°C) [4]. The freezer itself should also be placed correctly: if the environmental temperature drops below 10°C (50°F), oil might be too viscous and work less well or damage the compressor[7], so please refer to the operating manual before deciding on an unheated garage.
The tables given here assume proper storage. Food which requires refrigeration is considered unsafe if left for over two hours at temperatures between 41–135°F (5–57°C) [5].
The Tables
Regardless of the table below, if a food shows signs of spoilage (including mold, with some exceptions described below), its past its shelf-life. Note that the lack of spoilage does not imply safety.
Uncooked Proteins




Item
Fridge
Freezer
Sources




Ground (meat, poultry)
1–2 days
3–4  months
[KC]


Non-ground meat
3–5 days
steaks: 6–12 monthschops: 4–6  monthsroasts: 4–12 months
[KC]


Poultry
1–2 days
whole: 12 monthspieces: 9 months
[KC]


Eggs
in shell: 3–5 weeksseparated: 2–4 days
in shell: not recommendedwhites: 12 monthsyolks: not recommended
[KC]


Bacon
1 week
1 month
[CFG]


tofu
1 week
5 months
[CFG]


fish
1–2 days
lean: 4–8 monthsfatty: 2–3 months
[CFG]



Cooked proteins




Item
Fridge
Freezer
Sources




luncheon meat
opened: 1 weekunopened: 2 weeks
1–2 months
[KC]


cooked meat and poultry
3–4 days
2–6 months
[KC]


cooked fish
3–4 days
1–2 months
[CFG]


hard boiled eggs
1 week
not recommended
[KC]


hard sausage
2–3 weeks
1–2 months
[CFG]



Dairy




Item
Fridge
Freezer
Sources




butter
1–3 months
6–9 months
[CFG]


hard cheeses
opened: 3–4 weeksunopened: 6 months
6 months
[CFG]


soft cheeses
1 week
6 months
[CFG]


cream cheese
2 weeks
not recommended
[CFG]



Sauces




Item
Fridge
Freezer
Sources




mayo
commercial: 2 monthshome-made: see below
not recommended
[CFG]


gravy, broth
3–4 days
2–3 months
[CFG]




For home-made mayo, there don't seem to be official shelf-life estimates.
Seasoned Advice has a question on this,
Making &quot;long(er)-life&quot; homemade mayonnaise.
Vegetables
Freezer times are given for cooked or blanched, then frozen. Generally, this is
required, otherwise enzymatic degradation will occur. See &quot;Where can I go for
details on a specific food?&quot; for where to find specific steps for each vegetable.
Refrigerator and shelf times are for storage raw.
If a column is -, it means that storage type is not recommended. &quot;Ripe&quot; means
&quot;until ripe&quot;.




Item
Shelf
Fridge
Freezer
Sources




Asparagus
-
3–4 days
8 months
[FK]


Green beans
-
3–4 days
8 months
[FK]


Beets
1 day
7–10 days
6–8 months
[FK]


Cabbage
-
1–2 weeks
10–12 months
[FK]


Carrots
-
3 weeks
10–12 months
[FK]


Celery
-
1–2 weeks
10–12 months
[FK]


Garlic
1 month
1–2 weeks
1 month
[FK]


Herbs (fresh)
-
7–10 days
1–2 months
[FK]


Lettuce (iceberg)
-
1–2 weeks
-
[FK]


Lettuce (leaf)
-
3–7 days
-
[FK]


Mushrooms
-
2–3 days
10–12 months
[FK]


Onions, non-sweet
2–3 months
2–3 months
10–12 months
[ST]


Onions, sweet
1–2 months
1–2 months
10–12 months
[ST]


Peppers
-
4–5 days
6–8 months
[FK]


Potatoes
1–2 months
1–2 weeks
mashed: 10–12 months
[FK]


Squash, summer
-
4–5 days
10–12 months
[FK]


Squash, winter
1 week
2 weeks
10–12 months
[FK]


Tomatoes
ripe
2–3 days
2 months
[FK]



Fruits
Many fruits must be at least partially cooked (blanched) before freezing in
order to deactivate enzymes that would otherwise degrade quality while in
storage. Some are best frozen packed in acid (lemon juice or citric acid)
and/or syrup. See &quot;Where can I go for details on a specific food?&quot; for where to
find specific steps for each fruit.
If a column is -, it means that storage type is not recommended. &quot;Ripe&quot; means
&quot;until ripe&quot;.




Item
Shelf
Fridge
Freezer
Sources




apples
1–2 days
1–3 weeks
cooked: 8 months
[FSG], [FK]


apricots
ripe
2–3 days
-
[FK]


bananas
ripe
1–2 days*
peeled: 1 month
[FK]


berries
-
1–2 days
4 months
[FSG], [FK]


citrus fruit
10 days
3 weeks
-
[FSG]


grapes
1 day
1 week
1 month
[FK]


juice
-
6 days
8 months
[FSG]


melons
1–2 days
1 week
balls: 1 month
[FSG], [FK]


generally:

3-5 days






*: bananas stored in the fridge will blacken. This is not a sign of spoilage, and they can be eaten safely.
Cooked dishes
2 hours on the counter, for all of them, unless you prepared a known shelf-stable item which generally does not go in the fridge (like cookies, or a canned jam, or others). It does not matter how long the individual components would have lasted on their own.
Refrigerated: generally 3–4 days in the fridge. This includes pizza, soups, stews,
casseroles, pies, and quiche [KC]. Some salads get a fifth day [CFG].
Freezer time is generally under three months.
Infused oils
Putting any plant matter in oil (such as garlic, chillies or herbs) creates the danger for botulism, a rare but fatal disease. Thus infused oils are not shelf-stable. They can be kept in the refrigerator for 3-5 days, discard them earlier if you see cloudiness or gas bubbles. Or buy commercially produced infused oils, they have been treated with industrial methods to kill the botulinum spores.
Shelf-stable until opened




Item
Unopened
Opened, in fridge
Source




Commercially canned, low-acid (meat, poultry, fish, soups, stews, vegetables)
2–5 years
3–4 days
[CFG]


Commercially canned, high-acid
12–18 months
5–7 days
[CFG]


Olives
12–18 months
2 weeks
[FK]


jam, jelly, preserves
1 year
6 months
[FK]


shortening (Crisco)
8 months
3 months
[FK]



Pantry (not refrigerated even after opening)




Item
Shelf life
opened (if different)
Source




Baking powder
18 months

[FSG]


Baking soda
2 years

[FSG]


beans (dry)
1 year

[FK]


Bouillon
1 year

[FSG]


cornstarch
18 months

[FK]


extracts
3 years

[FK]


flour
white: 6–12 monthswheat: 1 month

[FK]


herbs (dry)
1–2 years
1 year
[FK]


honey
1 year

[FK]


pasta (dry)
2 years

[FSG]


egg noodles (dry)
6 months

[FSG]


rice (dry)
white: 2 yearsbrown: 6–12 monthsflavored: 6 months

[FSG]


vegetable oil
6 months
1–3 months
[FSG]


vinegar
2 years
12 months
[FSG]



General tips for storing foods
How do I freeze fruits and vegetables?
Fruit. Ripe (but not overripe) fruit should be used. Wash them, and sort according to size. Working in small batches, remove pits, seeds, and blemishes. For fruits that turn brown, apply ascorbic acid or sugar and citric acid. Most fruits benefit from packing in dry sugar or a sugar syrup. Small, whole fruits (e.g., berries) can be spread on a tray and individually frozen, then packed in a freezer bag or other airtight container.
Vegetables. Most vegetables need blanching. To blanch, immerse in boiling water over high heat or steam over rapidly boiling water (steam). After blanching, transfer to ice bath for the same amount of time as blanched. Drain and dry. Freeze either by packing in a freezer bag with as much air as possible removed, or by allowing to freeze on a tray, then putting in a bag or other container.
General guideline is 8–12 months for best quality.
The above is a very quick summary of Iowa State University's Preserve the
Taste of Summer: Freezing: Fruits and
Vegetables. The
five-page document includes full details on over forty fruits and vegetables.
Feel free to ask here on Seasoned Advice if that guide doesn't answer your
question.
What about mold?
Some foods are expected to have mold in them (e.g., P. roqueforti in
Roquefort cheese). Unexpected mold, however, is something to be concerned
about. Mold can grow even on refrigerated foods, and even those high enough in
salt or sugar to deter bacteria. Some molds produce mycotoxins. Mold growth can
be minimized by cleaning the refrigerator every few months (use a mixture of 1
tablespoon of baking soda per quart of water, then rinse with plain water, then
dry), by keeping dishcloths, sponges, mops, etc. clean and fresh-smelling; and
keeping indoor humidity levels under 40%.
In general, the visible surface mold on a food is only a small part of the
actual mold growth. For most foods, any visible unexpected mold growth means
you should discard the entire item. There are several exceptions:




Food
How to handle mold




Hard salami, dry-cured country hams
Scrub mold off surface.


Hard cheese
Cut at least 1 inch around and below mold spot, do not cut through mold.


Cabbage, bell peppers, carrots
Cut at least 1 inch around and below mold spot, do not cut through mold.




Everything else, including soft or shredded cheese, soft fruits and vegetables,
bread, peanut butter, jams and jellies, sour cream, yogurt, luncheon meats,
casseroles, and cooked pasta should be discarded.
All this information comes from the USDA FS&amp;IS's Molds on Food: Are They
Dangerous? fact
sheet.
Where can I go for details on a specific food?
The web site StillTasty maintains a comprehensive list
of food storage times, notes, and procedures for a wide variety of food items.
They draw information from a variety of reputable
sources and should probably
be the first place you check.
Another good source of information is the Food Marketing Institute's Food
Keeper. This is also a searchable database of foods.
Finally, if neither of those two references answer your question, you're at the
right web site. Please ask here on Seasoned
Advice.
Bibliography

[CFG]: USDA FS&amp;IS Cooking for Groups: A Volunteer's Guide to Food Safety
[KC]: USDA FS&amp;IS Kitchen Companion: Your Safe Food Handbook. February 2008.
[FK]: Food Marketing Institute, Food Keeper
[FSG]: Julie Garden-Robinson, North Dakota State University, FN-579 Food Storage Guide
[ST]: StillTasty.com, Keep It or Toss It?

Note
This is a work-in-progress. I still need to finish adding information to it. Also, this answer is a community wiki, please feel free to improve it.