The environment in which your coffee beans are kept has a huge effect on the flavor, aroma, and mouthfeel of your brew. The main factors that need to be controlled are air, moisture, heat, and light.
Air exposure is perhaps the easiest way for your beans to deteriorate. After purchasing a batch of beans, it is recommended that you store a small quantity separately in a canister as a daily supply. The bulk of the beans should be stored in a large, airtight canister, from which you top off the smaller container when it is empty. This reduces the number of times that the beans are exposed to oxygen, greatly slowing deterioration. Ideally, coffee beans should not be stored in paper, because paper allows airflow; heavy-duty foil or plastic are better alternatives for keeping the beans from being exposed to air.
Moisture also needs to be controlled to keep your beans in prime condition. When the roasted bean is exposed to moisture, it can be ruined almost immediately, and fungal contamination can occur. It is not simply dampness or humidity that you need to be aware of in guarding against the threat of moisture; significant changes in temperature can cause condensation. For this reason, you should not store your coffee beans in the refrigerator or freezer.
There are some sources that state that refrigeration preserves the coffee bean, ensuring freshness, however this is actually detrimental to the bean. If whole coffee beans must be purchased in bulk, as a last resort they can be stored in the freezer for up to a month in airtight bags, removing as much air as possible. Protecting the beans from light is less of an issue in this case, because the freezer provides a dark environment.
Protecting your coffee beans from heat is often harder than it seems. If you live in a location where the temperature fluctuates, you simply cannot be sure that your beans are stored at a constant temperature. The best advice is to find the coolest place in your house—at the back of a cupboard and as low to the ground as possible, making sure there is no heat source or anything that may cause the temperature to fluctuate, such as a hot-water pipe or sink drainage, nearby. The storage place should also be dark to protect the beans from the harmful effects of light.
Coffee starts to lose its freshness soon after roasting, so it is important to purchase freshly roasted beans and use them within one to two weeks. An easy way to tell how fresh coffee beans are is simply by looking at the package and checking for a valve. Coffee emits carbon dioxide after roasting, so a valve allows gases to escape and prevents the bag from popping. To vacuum-seal coffee, it needs to have released all of its carbon dioxide, so it is left to rest before bagging. Consequently, the vacuum sealing preserves coffee longer during transportation and sitting on the supermarket shelf, but the product may not have been at its peak when packaged. The safest solution is to purchase from local roasters in small quantities so that you can be assured that the beans are fresh.
Coffee should always be purchased and stored as whole beans. You can source the finest premium or specialty coffee, but if it is preground, your cup will never be able to attain the flavor of freshly ground beans. Grind what you require only as you need it, and store the remainder of the beans whole in airtight glass or ceramic containers in a cool, dark place.