To maintain freshness, coffee beans or ground coffee should be stored in an airtight container in a cool, dry place away from direct sunlight, heat, and moisture. Exposure to air, heat, and light can cause coffee to lose its flavor and aroma. Ideally, coffee should be stored in an opaque, airtight container at room temperature. Ground coffee loses its freshness more quickly than whole beans, so it's best to buy only what you'll use within a week or two. Properly stored, whole bean coffee can stay fresh for 2-3 weeks after roasting.