If possible, I try to get to the grocery store in the early morning. One, it's not too crowded at that time. Two, often times there are loads of 40% off deals waiting for me. Produce, bakery goods, and meat close to their expiration date are marked down to sell fast and make room for the day's fresh items. This is true for discount clubs like Sam's too.
With my brood, food goes fast so if I buy something on the verge of expiration it's no big deal. If it doesn't look like it'll get eaten that day or next, there is always the freezer. And over-ripe fruit makes great fruit leather!