Large bakeries re-purpose as much as possible. When we made cakes for the case, we kept them there for five days. They were still fresh enough because they were sealed with a heavy buttercream. If they didn’t sell in five days, we’d cut them into large single servings and add another three days to the sticker. If it still didn’t sell, we’d likely cut it up into little free samples. This store made good, moist cakes and they held up pretty well for those time frames, and we hardly ever had to throw out a slice of cake. Bakeries often freeze cakes. We always froze the unfrosted caked — it actually makes them moister. Once they were frosted and garnished, they went back into the freezer to rotate out to the case as needed.
You can’t tell whether a bakery wraps its unfrosted cakes or keeps ready-to-sell cakes in a closed rack to avoid drying in the freezer. Bakery clerks are often discouraged from revealing the storage practices and/or age of products. At some point, you just have to decide whether or not you trust that bakery for providing quality products. Always buy a buttercream-frosted cake rather than whipped topping — whipped topping allows more air to reach the cake, and it loses its moisture into the cake and becomes dry and unpleasant. Buttercream seals the cake well and keeps it fresh longer. Ask for something not available in the case, like a frosted but ungarnished cake or a cake frosted in a particular color. They’ll have to put that together for you, so you’ll know it hasn’t been sitting around.