Green Beans - The length of time that green (unroasted) beans can be stored depends on a variety of factors, the most important of which are humidity, air circulation and temperature. They must not be subjected to huge variations in temperature or the flavour of the end product will decline rapidly. Ideally they should be stored in a stable environment and used within two years. The ideal humidity is around 50 to 55 percent and the ideal temperature around 22 degrees centigrade (72 degrees fahrenheit). It is important not to put green beans into an airtight container because they need to breathe. It is best to store them in a jute sack or a paper bag, not in plastic, and keep them out of strong sunlight.
Roasted Beans - Roasted coffee beans gradually deteriorate after they have been roasted and are best used within 6 months, but they must be properly stored. To prolong their freshness they can be stored in air tight packaging in a freezer for up to 12 months and used in small quantities as and when required. However there is a debate about the effect of the moisture that the beans are exposed to as a natural side effect of defrosting, and of course the frozen beans should never be used in a grinder straight from the freezer! The fridge is a better option for storing roasted beans but again they should be stored in an airtight container or in an unopened valve bag, although there is a similar issue with condensation. It is very important to keep the storage containers clean since the oils from the roasted beans will build up and become rancid damaging the flavour of the beans. The best plan is to store your roasted beans in an airtight container in a cool place out of direct sunlight, and to use them as quickly as possible.
If you roast your own beans it is recommended that you only roast a week's worth of coffee beans at a time.
Ground Coffee - Ground coffee deteriorates very quickly. Ideally you should grind the coffee immediately before use but if you choose to buy it ready-ground then it is best to buy it in very small quantities and use it as quickly as possible. Modern production processes for ground coffee purge the oxygen from the packaging to prolong the shelf life, but once the packaging is opened the coffee will be exposed to oxygen and will deteriorate quickly. Observe the "best before" date on unopened valve bags or pressurised tins of ground coffee.