As soon as coffee beans are roasted, they start to age. Freshly roasted coffee beans need to rest for 8 hours at least before they are ground and brewed to allow carbon dioxide to escape. The beans will reach their fullness of flavour within 48 hours of roasting, and that prime taste will only stay for about a week. After that, beans start to become stale. But there are ways of ensuring that your beans are always at their freshest. Roasted coffee beans are affected by air, moisture, heat and light (in that order). So minimize your beans' exposure to these.
Buy only what you need for a week and no more.
2. Store your beans in an air tight container.
3. Don't store your beans in the fridge or freezer which would expose them to excess moisture.
4. Store your beans in a cool and dark cupboard. Cupboards close to appliances or to outside walls exposed to sun are not recommended.