Just last year, somebody wrote a comment stating that my food storage claims that many foods remained pristine 7-10 years after being stored was an exaggeration and they complained that I seemed to routinely exaggerate most of my storage life estimates. They didn't realize that my education came from the same sources that theirs did, only my hands-on practical experience was that the "official" storage lives published were drastically conservative, even for food that was stored with few precautions.
I expected my food to expire at the same time that the "experts" had suggested. They didn't. I have since concluded that most of these conservative shelf lives you see in print are to avoid being sued for causing somebody to get food poisoning.
The two most critical environmental hazards to avoid are humidity and temperature. Some varieties of damp will make food go off overnight. High temperature will foster bacteria as well. You should store your food in sealed containers somewhere it is dark, cool and dry. This alone will keep most kinds of foodstuffs edible a long time. If you want to pack your own long term storage food, get oxygen absorbers and mylar bags and seal the food up in airtight containers. This can make stuff last practically forever. If you're packing for these kinds of time frames, I will give you the same advice I do for software development : the documentation should travel with the implementation. You have to label that box/bag/drum on the spot with the date packed, a list of the contents and any special notes about sealage or methodology, i.e. oxygen absorber and mylar. We have a standard form at Vault-Co that goes on everything with a water resistant spray adhesive the second the lid is tamped down. Later on you can put a fancy bar code on the drum or an RFID tracking tag but make sure a human-readable failsafe label is on the food so if it's found by a supermutant or your children in the far future, they will know what is inside it.
The cheapest and most ubiquitous foods for really long, long-term storage are powdered milk, white rice and rolled oats. If you kept these sorts of foods dry and cool I expect they could be eaten fifty years from now and perhaps even sustain you for a while until you found something better. Since sugar, brown sugar and malt make rolled oats and powdered milk really easy to eat, they are excellent companions for these foods. I am of the opinion that white sugar kept dry will last at least ten years without an oxy absorber and still remain safe to eat. It doesn't take much more to supplement this diet and you will survive the very worst of famines in combination with clean drinking water.