The best way to keep coffee fresh is to only have enough coffee to last you a reasonable amount of time; a one-week supply is what we recommend. By buying your coffee on a more frequent schedule, it will help guarantee that each cup achieves its maximum taste potential.
Sunlight is the easiest of coffee's natural enemies to combat. It is best to keep your whole bean coffee in a cool, dry place, preferably between 50 and 70 degrees Fahrenheit, and out of direct light. A cupboard or pantry is ideal because the light is limited and temperature doesn't fluctuate as much.
You should store freshly brewed coffee in a preheated vacuum container with a glass or stainless steel inner lining, like a coffee airpot or thermos. To preheat the container, fill it with hot water and let it stand for a few minutes. Dump out the water & replace with coffee. A container of this kind can keep freshly brewed coffee hot for a long time. Additionally, it will help keep the freshly brewed coffee from breaking down and losing its flavor.