Hint: It's not vacuum packing.
There's been a great article recently by Sucafina Specialty detailing their experimental results in exploring the ideal way for storing coffee. For this article, their primary focus was on green coffee but the final conclusion would be the same for roasted coffee.
More than hot temperatures, humidity or sunlight, oxygen is the biggest cause of degradation in coffee quality. Perhaps the only factor more damaging for roasted coffee would be actual contact with water itself.
Best practices for storing coffee
The primary consideration should be to isolate the coffee from oxygen.
With specialty green coffee, this is now commonly done with grainpro bags that helps to hermetically seal and protect the coffee within. This is less common with commodity coffees which are stored only in jute bags. This exposes it to constant contact with the jute bag material (which is absorbent and retains foul odours and moisture) and lots of oxygen since it is not airtight. As per the test done by Sucafina, air-conditioned storage actually did not have a significant impact on the green coffee.
With roasted coffee, most coffee bags are typically well-sealed and avoid entry of oxygen (regardless of the one-way valve). The real damage happens when you purchase a bag of coffee and open it. This immediately introduces oxygen into the bag which starts the degradation process.
Ideally, you would aim to squeeze out as much of the air before resealing the bag but this will not drive out all oxygen. Multiple usage will also continuously expose the coffee to oxygen as the bag gets constantly re-opened. Hence, it is recommended to purchase smaller quantities which you can finish quicker and avoid overly stale beans. If you prefer to buy larger quantities for convenience, the best storage would be to break the coffee into smaller airtight bags/containers and use them separately. This would avoid additional exposure to oxygen to the entire batch of coffee.
Why Vacuum Packing is not recommended
There are a couple of products on the market that assist in vacuum sealing or driving out air from an airtight container. While this effectively isolates the coffee from oxygen, it also introduces a number of unwanted side effects to the coffee.
With green coffee, vacuum packing has gained popularity over recent years due to the increased ease of portability it provides. However, there have been multiple observations about the impact of vacuum packing on overall quality. The first is the death of the embryo within the green coffee due to the absence of air.
The death of the coffee embryo
The inability of the coffee to "breathe" causes the embryo, which is supposedly linked to the fresh vibrant flavours of the coffee, to die. Multiple roasters have reported a rapid decrease in coffee quality and flavours when roasting green coffee stored in vacuum sealed bags. I am rather sceptical of this theory since it is hard to test and prove scientifically, but it has been mentioned by many veteran roasters so I will leave it here.
The pressure of Vacuum on moisture
The second observation (more plausible in my opinion), relates to the impact of vacuum packing on the moisture distribution within the green coffee. The vacuum suction creates an uneven pressure gradient within the interior of the green coffee and the external environment. Especially with fresh green coffees which have not had their water activity stabilized, this can cause moisture within the green beans to move further out to the surface of the bean instead of being evenly distributed within the bean.
The result is an uneven distribution of moisture content within the bean which worsens over time. This uneven distribution of moisture negatively impacts the roasting process and the ability of the roaster to produce an even, well-roasted and consistent coffee.
The pressure of Vacuum on volatile gases
The same effect occurs with roasted coffee except with gas instead of moisture. The vacuum suction results in an uneven pressure gradient that draws out volatile gases and aromatics from the roasted coffee beans. Over time, this causes the coffees to lose the volatile gases (responsible for its amazing aromatics) and impact the final quality in the cup.
This becomes accentuated in espresso as these trapped gases are partially responsible for slowing down the flow of water and allow a longer contact time (extraction) of the coffee. The lack of gases will result in a much faster flowing espresso and impede optimal extraction.
When to Vacuum Pack
The only time that vacuum packing is recommended is when freezing coffee. This is necessary to avoid water crystals and condensation forming within the coffee which will severely damage its quality and flavours. Otherwise, the simplest recommendation of an airtight bag/container stored away from excessive heat, light and humidity is still the best.