Heat, light, air and damp all work against an open bag. What helps, what makes no difference, and the one piece of common advice to ignore.
Coffee goes stale in four ways, and only one of them is time. The other
three are air, light and heat, and all three are easier to control than
people think.
Air is the main one
Roasted coffee gives off carbon dioxide for days after it leaves the
roaster, which is why a good bag has a one way valve in it: the gas gets out
and the air does not get in. Once you break the seal, that protection is
gone and oxygen starts working on the oils that carry most of the flavour.
So the single most useful habit is to close the bag properly. Press the
air out, roll the top down, clip it. If you decant, decant into something
that actually seals, and into a container the coffee nearly fills: a half
empty jar is a jar of air.
Light and heat are the next two
Keep the bag in a cupboard, not on the counter beside the kettle and not
on a windowsill. A Nairobi kitchen in the afternoon gets warm, and warmth
speeds up everything that is already happening inside the bag. A dark
cupboard at room temperature is all the storage coffee needs.
The advice to ignore
Do not keep coffee in the fridge. It is the one piece of storage advice
that gets repeated most and it does real damage. A fridge is humid, coffee
is porous, and the bag will take on moisture and the smell of everything
else in there. Worse, taking it in and out condenses water onto the beans
every time.
The freezer is a different argument and a narrower one. If you have more
coffee than you can drink in a month, freezing it sealed, in portions you
will not reopen, does hold it. Take a portion out, let it come to room
temperature before you open it, and do not put it back.
How long you actually have
Whole beans, sealed and stored properly, are at their best for about a
month after roasting and perfectly good for two. Ground coffee loses the
same ground in a week, because grinding multiplies the surface the air can
reach. That is the real argument for buying beans and grinding as you go,
and it matters more than any container you buy.
Nothing here makes old coffee young. It slows down the thing that is
happening anyway.