Coffee, like produce, is perishable. Not only is roasted coffee perishable, but how it is stored drastically affects how quickly it perishes. Beans kept properly maintain their freshness for about ten days. Coffee kept improperly can go bad within minutes. The first thing one can do to extend their coffee’s freshness life is to get a grinder. This is also one of the first things I often suggest to people when they ask me how they can improve their coffee at home. Get a grinder. Buy, borrow, find, construct, inherit, stumble upon, or ask nicely, but somehow acquire a grinder. Then make it a point to use said grinder (not store it away) and use it effectively (grind beans fresh for each brew).
Whole beans keep their freshness for days to weeks, grounds usually for minutes to days– this depends a lot on packaging too. Coffee beans go stale by oxidation (the same type of process that is used to process tea leaves into black tea). The rate of oxidization increases with oxygen concentration (whether is be in the form of air or water, therefore dry vacuum sealing and/or nitrogen flushing is preferred), the rate of oxidation is also increased, like most reactions, by increased temperature or light. So, staying practical, it is best to store whole coffee beans in an opaque airtight container in a cool dry place. We happen to package our retail bean purchases in just such a container!