Some foods have naturally long shelf lives, and if stored properly, will keep for months or years. Other foods spoil quickly, usually due to a high oil and/or moisture content, and will last a long time only if they’re dried, canned or otherwise preserved. There are numerous foods that spoil faster than you’d think.

There is great interest in long-lived foods among so-called preppers or survivalists, who anticipate having to live off the grid when widespread calamity strikes. Embracing the idea of lengthy self-sufficiency, they exchange tips on stockpiling particularly long-lasting foods.

You don’t have to be worried about doomsday, however, to see the advantages of stocking a pantry with things that will be good to eat for long periods of time. Unexpected guests, power failures and simply the kind of inertia that makes a trip to the market or going out to eat just too much of a project – these are all instances when anyone would be glad to have shelves stocked with the makings of a meal.

Many kinds of food, including both fresh and dried produce, are known for their longevity. 24/7 Tempo has assembled a representative list of examples in many categories, including some that will last for weeks, and some that are virtually immortal.

In all cases, the estimated shelf life is for foods stored at room temperature or slightly cooler – not in the refrigerator or freezer, both of which will extend the lifespan of most items substantially. Evolving technology has brought many more options to the grocery store freezer, and there are a number of foods you couldn’t buy frozen 35 years ago.

Note that moisture and high temperatures will shorten the lives of most foods, and that foods tend to change over time in color, texture, and/or flavor – so while they may last months or years, they may be at their prime somewhat earlier.

1. Potatoes

• Shelf life: 2 to 5 weeks

If stored in a cool, dry, dark place. Yukon Gold, red, and fingerling potatoes will last from two to three weeks. Larger white or russet potatoes can last for three to five weeks. Sweet potatoes have about the same shelf life. Don't store them next to onions, however: The two might go together well in cooking, but raw, each gives off gases and moisture that might cause the other to spoil faster.

2. Onions

• Shelf life: 1 to 2 months

As with potatoes, store these in a cool, dry, dark place for maximum longevity. And, as above, don't store them with potatoes; both will spoil faster.

3. Peanuts

• Shelf life: 1 to 2 months

Peanuts in their shell, especially when kept cool and dry, are perfectly happy in the pantry for as long as two months.

4. Winter squash

• Shelf life: 1 to 3 months

The various kinds of thick-skinned winter squash – including butternut, spaghetti, acorn, kabocha, and hubbard, among others – are among the most durable of fresh vegetables.

5. Apples

• Shelf life: 5 days to 6 months

Apples kept in a fruit bowl at room temperature will generally last five to seven days. When stored in a humid place at a temperature of 30º to 40º F, however, they can stay crisp and fresh for as long as six months.

6. Tea

• Shelf life: 6 to 12 months past "best by" date

Dried tea leaves, whether loose (in a sealed container) or in teabags (in an unopened box) can easily last a year or more if they're not subjected to moisture or humidity. The tea does tend to lose flavor over time, though.

7. Powdered milk

• Shelf life: 1 to 1½ years

The color, texture, or flavor of powdered milk might change as it ages, but it will still be perfectly usable and safe for at least 18 months.

8. Beef jerky

• Shelf life: 1 to 2 years

Beef jerky and its predecessors in various parts of the world were invented to last a long time as sustenance in the wilderness and on long journeys. It's lean, dry, and salted – all qualities that add to its ability to stay edible for a long time.

9. Canned fruits and vegetables

• Shelf life: 1 to 2 years past "best by" date

Canning is an extremely efficient means of preserving food. Generally speaking, if canned foods aren't subjected to intense heat, their contents should stay good for two years or more. Beware, however, of dented cans or those with swollen tops, which may indicate the presence of bacteria inside.

10. Dried pasta

• Shelf life: 1 to 2 years past "best by" date

Made with just semolina flour and water, then thoroughly dried, this pasta is fairly indestructible. Its richer counterpart, fresh pasta, usually made with eggs, is much more perishable and should always be kept refrigerated.

11. Bouillon cubes

• Shelf life: 2 years

Oxygen and moisture are the enemies of these useful little blocks of instant soup or stock. Keep them dry and well sealed, and 24 months is probably the minimum they'll last.

12. Peanut butter

• Shelf life: 2 years

An unopened jar of peanut butter should last longer than a couple of years at room temperature, but with time, the oil will separate, the peanut butter might dry out, and the flavor may fade. Two years is likely the maximum for the best quality.

13. Dark chocolate

• Shelf life: 2 to 5 years

Because milk chocolate contains dairy, it will go bad more quickly than chocolate with high cacao content and little or no milk. Warm temperatures are the enemy of dark chocolate, and while it should last for a couple of years at temperatures up to around 75º F, it will keep for as long as five years if the thermometer rests between 60º and 65º F. Chocolate exposed to high temperatures can develop white spots, but these are harmless and don't affect the flavor.

14. Canned or vacuum-pouched tuna

• Shelf life: 3 to 5 years after "best by" date

Tuna is a hardy fish and one that takes well to canning (and in more recent times, to vacuum-packing in pouches). For optimum flavor and texture, don't keep it longer than five years after the producer's "best by" date.

15. Dried beans

• Shelf life: Indefinite

Dried beans are pretty much indestructible if they're kept dry, though they begin to lose their moisture after a year or two. As they age, they will require longer pre-soaking and/or cooking times to become tender.

16. Honey

• Shelf life: Indefinite

Though honey is often sold with a "best by" date (usually somewhere between two and five years from the time it's packaged), that's because over time it may darken and form sugar crystals – perfectly harmless, but off-putting to some consumers. Pure 100% undiluted honey in an unopened jar (stored away from heat) will still be edible years, decades, probably generations down the road.

17. Liquor

• Shelf life: Indefinite

Everybody knows that wine can last a long time, sometimes greatly improving as it ages. But it can also go bad quickly through exposure to extreme heat or cold, oxidation through leaky corks, and just the natural evolution of its chemical constituents over time. Not so hard liquor. Unopened bottles of spirits are virtually unchanging. Their high alcohol content preserves them and they don't age. The only exception is with some sweet liqueurs, from which, as the years pass, some of the sugar content will precipitate out, forming crystals and leaving the liqueur slightly less sweet.

18. White rice

• Shelf life: Indefinite

Brown rice might be healthier, but it has a high oil content and so can go bad in a few months' time, while white rice – if you keep it dry – will last forever. The only possible problem, other than moisture, is the sudden appearance of tiny black bugs among the rice grains. These are rice weevils or flour bugs, and they've either found their way into the package through microscopic openings or their eggs were harvested along with the rice itself. Storing rice in thoroughly dried airtight containers will stop them from getting in; if they're already there, though, the rice should be discarded.

24/7 Wall Street is a USA TODAY content partner offering financial news and commentary. Its content is produced independently of USA TODAY.