Let's look at bags first. If your favorite coffee can be found in a supermarket or other kind of store, and isn't scooped as whole beans or ground fresh on-site, look for brands packed in bags with a one-way valve. They are common. You can spot the valve, which looks like a little round button, near the top of the bag. In addition to protecting contents from moisture and light, one-way-valve bags allow coffee to be packed soon after roasting, without forced degassing.
That's a good thing, because it means carbon dioxide remains present in the bag, pushing out oxygen to protect against oxidation and promote proper aging. The valve also allows small amounts of carbon dioxide to escape from unopened bags, protecting against the bag exploding during normal rises in atmospheric pressure. But the valve giveth and taketh away; escaping along with the carbon dioxide are those essential volatile aromas. Bottom line: You'll want to open one-way-valve bags within a few weeks of the roasting date.
But how to know the roasting date of non-store-roasted, bagged coffee? Forward-thinking roasters like Intelligentsia and some others have started to stamp the roasting date on bags. Otherwise, there is an unscientific approach that works pretty well: hold the bag with the valve close to your nose, squeeze gently and let a little gas escape. If the coffee is of a good age, you'll sense good, intense aromas. [Corby's note: But remember, those escaping aromas mean less in your cup! The problem, as Giorgio points out, is if the good aromas have already been lost, in which case you smell nothing, or whether the odor is frankly stale, in which case you shouldn't buy it.]
Try to use up the contents quickly—ideally, within a few days to a week—because of the ensuing rapid staling. The one-way valve fully opens the first time you open the bag, and serves no purpose afterwards.
Know that there will be some flavor and aroma loss. I don't recommend freezing coffee intended for espresso under any circumstances.
Non-valve bags are the norm for coffee packed fresh at your local roaster or café. [Corby's note: Though Starbucks and other large roasters used to, at least, ship bulk coffee in valve-lock bags.] They are a viable packaging option if the coffee going inside was freshly roasted three to five days beforehand, allowing for sufficient initial degassing. Maybe a day or two on the long side won't make a big difference, but more than that, and you'll experience a variety of issues, like the overabundant crema and taste flaws described earlier. I strongly recommend asking the barista or counterperson how recently your choice was roasted. If the person isn't sure, I'd recommend not buying. When you do buy, start using fresh-packed coffee right away—simply keeping the bag sealed doesn't stop the rapid degassing process—and finish it within a few days to a week.
If finishing a bag that quickly isn't in the cards, you can extend your coffee's life through refrigeration. The key is first transferring it to an airtight container, then making sure to bring it to room temperature before preparing, especially for espresso. [Corby's note: I don't think Giorgio's way! I never believe in refrigeration. Keep in an airtight bag at room temperature for five or so days, and that's it.] For longer-term preservation, you can put an open one-way valve bag or any non-valve bag in the freezer. Know that there will be some flavor and aroma loss. [Corby's note: a lot!] I don't recommend freezing coffee intended for espresso under any circumstances.
On to cans, where lots of confusion reigns. The most common canning process is vacuum packing, which does an excellent job protecting coffee from moisture, oxygen, and light—better than bagged coffee. You can store it for many months on the shelf, or in your pantry, before unsealing. But vacuum packing has one major flaw: The coffee must be completely degassed before packing, because there is no valve to let gas escape. Without degassing, vacuum-sealed cans are prone to expanding, or even exploding. The problem is that full degassing prior to canning causes immediate loss of very desirable, volatile aromas that come from coffee's natural aging process. So the tradeoff is clear: gain shelf life, lose some aroma and flavor.
The other major canning method, pressurization in a modified atmosphere, provides the best of both worlds: protection from staling-inducing elements while permitting proper aging though carefully calibrated degassing. Full disclosure: This method was invented in the 1930s by illy's founder, Francesco Illy, by chance as he was seeking the best way to transport his coffee from Trieste, Italy, to Switzerland. [Corby's note: And it's also Illy's opinion—its canning method best shows its own blend, as other companies' storage methods do, dictated by economy and technological prowess. And Illy has always been at the technological forefront.]
Left: coffee cells soon after roasting. Right: after pressurization.
This method puts newly roasted coffee in a rigid, sealed can with a special, one-way valve. As with vacuum packing, the air is drawn out. But a critical, extra step then occurs: the introduction of inert nitrogen gas, which pushes out any residual oxygen while increasing internal pressure, promoting proper aging from the start. As gas fills the can, the can's internal pressure increases, effectively slowing down future degassing.
During the initial 10 to 15 days, a strong aging effect takes place, improving the quality of the coffee. The high internal pressure spreads the natural oils around the coffee cells (see photo), creating a barrier whereby the volatiles normally forced out by escaping carbon dioxide remain trapped inside. The net effect is shelf stability for months, enabling long-distance transport with no quality loss.
Cain, Abel, and other biblical siblings aside, understanding coffee packaging can make your coffee a truly religious experience.