Keep the bag closed
Press out excess air and reseal it after every use. A proper airtight container also works, provided it does not spend its afternoons in direct sunlight.
Store it cool and dry
A cabinet away from the oven is usually enough. The refrigerator adds moisture and aromas, two houseguests coffee did not invite.
Grind what you need
Whole beans hold their character longer. Grind just before brewing when practical; when it is not, make good coffee anyway and continue with your life.
Buy an amount you will use
Fresh coffee rewards ordinary common sense. Smaller, regular orders beat a heroic pantry reserve that outlives three calendars.
The proof is in the cup. This is convenient, since that is where we were headed anyway.