They can go bad, especially in higher humidity. I buy large containers and just refill small ones to keep the large container good longer. I have multiple tanks so even the large containers don't last too long to worry about it going bad. I am not sure how long food lasts, but if I found something over 5 years old, I would toss it for sure.
I will repeat part of the advice I gave on that thread. The best place to keep your dry foods is in the freezer or fridge. Seal air tight, expel all air from the package.
Keep out only enough to last a week or two, whatever works for you, and never, ever leave cans or bags open, especially nearby the tank. Too easy for them to get dribbled on, the humidity is too high and it's just common sense to keep them sealed up.
If you buy food that's near expiry because it's marked down, freeze it immediately. Freezing can extend life of unopened packages for months at least. When you open it, only pour out enough for a short time, reseal the rest and back in the freezer, or fridge if there is no freezer available.
If you happen to own a vacuum packager, this is a great way to save money. Buy larger packages, break them into smaller portions, seal with the vac, then freeze. They'll last years so long as the seal is intact.
The main ingredient that goes bad in dry foods is the fat. The antioxidants added to preserve it do not last long once the pack is open, and rancid fats are very bad for any animal to eat, unless it is a carrion eater by nature. There is fat in flour too, which is the most common binder in many foods, just bear that in mind, as it isn't just the Omega fats or added fats, but the fat already in the ingredients too. Meat based foods have more fat naturally, so greater care should be taken with them.