Without question coffee is best when used within days of being roasted. Buying from a local roaster (or roasting your own) is the surest way to get the absolute freshest beans. Be wary of buying bulk coffee from supermarket display bins. Oxygen and bright light are the worst flavor busters for roasted beans so unless the store is conscientious about selling fresh coffee the storage tubes get coated with coffee oils which turn rancid. Coffee beans packaged by quality conscious roasters and sold in sturdy vacuum sealed bags are often a better bet.