Coffee beans taste best within a day or two of roasting. But if running out to your local coffee purveyor every few days doesn't mesh with your schedule, you can keep your beans fresh longer with proper storage techniques.
Whole-bean coffee usually comes packed in vacuum bags, which protects the beans during shipping and storage; open the bag, however, and it is no longer airtight. Pour the beans into an airtight container and store them in a cool, dark place.
Watch out for:
If you store your beans to avoid these elements, they can stay fresh for 1 to 2 weeks.
The cabinets around your oven and dishwasher get hotter and moister than the rest of your kitchen, so they're not a good location for coffee storage. Avoid cabinets on the outside wall for the same reason, especially if you live in an older building with drafts.
Store coffee beans whole. Grinding them exposes more of the surface area to air, causing the coffee to get stale more quickly.
If you have more coffee than you can use within a week or two, measure a few days' worth of beans into plastic freezer bags. Store them in the back of your freezer, where they aren't affected by temperature fluctuations near the door.
Coffee beans stored in the freezer stay fresh for about a month. Once you remove a bag from the freezer, treat it like freshly roasted coffee: store it in an airtight container in a cool, dark place for 1 to 2 weeks. Do not return the coffee to the freezer; doing so creates condensation that causes the coffee to deteriorate.