You have asked a question that has many possible answers and several seemingly contradictory answers may be true in the right circumstances or with the appropriate definitions. The following comments are my opinions: based on my coffee cupping abilities, several long term quality tests, corroborative information from several other qualified people in the industry and my practical experiences with coffee roasting and packaging.
1. Shelf life may be defined based on "best before" quality considerations and or "expiration date" food safety factors. Apparently the manufacturers come to widely different conclusions.
2. The packaging material manufacturers generally focus on food safety, and many of them endorse shelf life expectations of 2 years and greater. Certainly a can, glass, ceramic or multilayer laminated flexible film package can provide an effective barrier. Preventing oxygen and moisture in the atmosphere from entering the package is a basic requirement in extended shelf life. Oxygen and moisture are the most obvious contributors to overt coffee staling, and keeping atmosphere out of the package extends shelf life.
3. The packaging does not prevent the contents from the natural process of decay/deterioration/de-gassing Carbon Dioxide (CO2)/volatile molecules (aroma) escape/complex molecules (e.g. oils) fracture and degradation. These processes occur faster if the coffee is ground vs whole bean. The detrimental effects of these aging processes are compounded by exposure to atmosphere and absorption of oxygen and water and other non-coffee aromas and flavors (such as food and spice cross-contamination).
4. Ultimate freshness and cup quality may be entirely different than "acceptable" best by date standards, and different manufacturers and different consumers have varying thresholds of "acceptable".
5. I am already tired of typing and have only scratched the surface of this multifaceted topic. I want to watch CSI.
6. Coffee (cherry, green, roasted, ground, brewed) is not fresh indefinitely. Just because it may be food safe or may not have absorbed significant deteriorating factors, does not mean it is still as fresh as the day it was roasted.
7. Acceptable for some is not acceptable for others. I do not recommend freezing coffee, unless you live past the tree line in the arctic. Brewing coffee immediately upon grinding yields the best aroma and cup quality.
8. Treat coffee like fresh produce or fresh baked goods and you will enjoy better aroma, richer flavor, and more of the complexity and uniqueness of the farmer's and roaster's best efforts.
9. Ground coffee ages significantly faster than whole bean coffee.
10. Coffee is best within one to two weeks of roasting. Most manufacturers and consumers find little significant degradation within three to five weeks of roasting. Many find it acceptable within five to eight weeks of roasting. Some determine it acceptable up to 5 to 6 months after roasting - provided the packaging was originally nitrogen flushed and/or vacuum packaged, and the entire contents are brewed immediately upon opening the package. A few think it is acceptable for other people to drink it for one or two years (or even longer) after roasting.
11. If you buy fresh roasted coffee, and it tastes significantly better than the batch you just finished, then you should consider purchasing fresh coffee more frequently.
12. Try buying fresh roasted coffee every week (every other week at the most). Buy from a vendor that replaces their roasted inventory completely within a week and will tell you the roast date. If you mail-order, consider buying from a roaster that will roast to order, or ship a "standing re-order", or join a coffee of the month club.
13. Consider canned coffee equivalent in quality to cheap canned beans or spam. Consider frozen coffee equivalent to frozen fishstix. Compare pre-ground coffee to day-old bread. Consider that day-old bread may be better than instant coffee, but some of the $5 and $10 packages at the grocery store are not as good as instant coffee.
14. Try a few different $10 to $20/pound coffees from roasters committed to quality and freshness, Then consider that $0.20 to $0.60 per serving is a far better value than just about any beverage (including spirits, wine, cola, red bull, bottled water) other than koolaid.
15. Why not enjoy only fresh roasted, exceptional coffee? No matter how much it costs, it is still affordable and great value. Why tolerate mediocrity?
Please feel free to voice dissent or request more information or prolonged diatribe. I am curious to hear what others on this forum have to contribute, too. Clearly my opinion is biased, am I too far from center?