Everyone has an old can or jar of nuts lying around. But how long do they really stay fresh? Leave any nuts lying around too long, and theyll turn stale and bitter, ruining an otherwise festive snacking experience.

With baking season ramping up and so many pecan pies and party mixes to make and give, its imperative we keep our nuts fresh and our guests happy. Heres how.

The whole nut, and nothing but

You want the freshest nuts with the longest shelf life? Buy them whole, in the shell.

Once you start breaking down a nut, it just lessens the time for freshness, says Maureen Ternus, executive director of the Tree Nut Council Nutrition Council Research and Education Foundation.

But let’s be real. Most of us buy shelled nuts because theyre widely available and a lot more convenient for cooking and baking. Fortunately, whole shelled nuts are the next best thing to unshelled ones.

Some recipes call for a certain style of nut, such as sliced almonds, so if it looks like theres a good reason for it, its OK to stick with whats suggested.

But in general, buy whole nuts if you can help it, and then chop, dice, or grind as needed.

Raw deal

Almonds are the only nuts required by law to be pasteurized, the result of two salmonella outbreaks linked to raw almonds in the early 2000s. But other nuts are often processed in some way, whether by blanching, roasting, or steaming.

So unless you’re buying from a farmer’s market or roadside stand, what’s labeled a “raw” nut probably isn’t quite that.

“‘Raw’ does not necessarily mean it has not been processed. It may have been processed to reduce pathogens,” says Ternus. “But either way, that treatment does not affect the health benefits of nuts.”

Check your fats

The high oil content in nuts makes them prone to turning rancid. Those highest in polyunsaturated fats will go south more quickly than others, says Ternus. Walnuts top that list, pine nuts are pretty high, and almonds and cashews are on the low end. Use them accordingly.

No. 1 nut”

The most popular, highest-in-protein nut in America isnt technically a nut; its a legume.

Thats right, we eat more peanuts than any other tree nut, about 7 pounds a person each year, according to the National Peanut Board. The type consumed more than any other is the runner peanut, the predominant variety used to make commercial peanut butter and most peanut products.

Youve no doubt baked with or snacked on the other varieties: the small, red-skinned Spanish peanut; the Valencia, which is typically ground into natural” peanut butter or boiled in the shell; and the large, crunchy Virginia, more of a gourmet peanut, says Lauren Williams, a Peanut Board spokeswoman.

Our other favorite nuts? Almonds, pecans, walnuts, and pistachios, in that order.

Where do they come from

Not that far away, actually. California is the source of virtually all the almonds, walnuts, and pistachios we eat. Pecans, a native North American nut, come mostly from Georgia, New Mexico, Texas, and Arizona.

Oregon and Washington are the top hazelnut producers. The ever-popular peanut has three growing areas: the Southeast, Southwest, and around Virginia and North Carolina.

Cashews, Brazil nuts, pine nuts, and macadamiassave for Hawaii-grown onesare imported from Vietnam, Bolivia, China, and Australia, respectively.

Follow the crowd

Shop where you know theres high turnover.

And check out the bulk section. Buying nuts this way is often a better value than going the bagged route; as long as the bins arent covered in dust, you plan on actually using what you bring home, and you know how to store nuts properly.

So how should I store nuts at home?

An acceptable spot is a cool, dark cupboard or pantry. Most nuts will keep for up to six months that way, but as with most foods, the sooner you eat them, the better they’ll taste.

If youre the stockpiling sort, the refrigerator will gain you a month or two more in shelf life. But the best spot is in the freezer, says Ternus. Theyll stay fresh and crunchy for at least a year that way, and probably longer.

No matter what, keep nuts in a sealed container. They can easily pick up other odors, and the more you expose them to air, the quicker the oils in them will turn rancid.

How can you tell when thats happened? Oh, you can tell in one bite. Its not like its going to make you sick, says Ternus. But unlike the cashews of my youth, a rancid nut won’t make you smile, either.

Read more: