To quote Michael Jackson: “If you see a beer, do it a favour, and drink it. Beer was not meant to age.” Generally, that is true. However, some beers that are strong and/or highly hopped must age to reach their full flavour potential.
How a beer is conditioned and handled has a great affect on its shelf-life. Beer conditioned in the bottle (Home Brew Beer) or cask still contains live, active yeast and should be drunk as soon as possible. Most larger scale, commercial beers have been filtered or pasteurised to remove/kill the yeast and stabilise the product for the longer storage times encountered in the retail world.
In any case, stored beer should never be exposed to heat or strong light. Most literature says that 2-6months is optimal for beer to be at its best, as hop flavours start to diminish after this time. however I have drunk beers that were 2 years old in the bottle (kept in optimal conditions for that time) and they have tasted great!