When beer is stored for a long time it may not taste as fresh. This change in flavour is caused by a number of factors: 

Oxidation - The absorption of oxygen in the mash, the wort, and the beer leads to oxidation which can harm the flavour. The less oxygen absorbed in the beer during the brewing process, the longer the flavour remains stable. For these reasons some breweries degas the brewing water or fill the boilers from underneath. When filling the bottles, a small high-pressure jet of water is sprayed in the beer such that it froths up. The bottle is then closed. 

Refermentation - When a beer ferments in the bottle, all the oxygen that was in the bottle is used up by the yeast. Yeast cells need oxygen during the aerobic stage of fermentation. Then there is no oxygen left in the bottle to cause oxidation, such that the good flavour of the beer is preserved, even if stored for a long period of time. In other words, fermentation in the bottle is good for the shelf life of the beer. 

Acidity - In addition to oxidation, the acidity must be closely monitored. When boiling the mash and the wort, the pH value must be correctly set so that the proteins coagulate well, the right bitter substances are extracted from the hops, and so that the shelf life is thus guaranteed. 

Micro-organisms - The shelf life of beer is highly dependent on microbiological control. When lactic acid and acetic acid bacteria slip into the beer during the brewing process, the result is sour beer. The presence of micro-organisms in the beer not only provides strong flavour differences, but can also cloud the beer. One single bacterium is enough to make beer sour over time. That is why extremely sterile conditions are used during the brewing process. 

Beer that is to be stored for some time should be stored in a cool and dark place. Beer is sensitive to light, and with long term exposure to UV its flavour will change. If the area is too warm, the oxidation will proceed faster than at low temperatures. Oxidation also harms the flavour.