Longest-lasting is probably what you list, frankly. Rice, beans, etc. Pasta and canned goods are also very good for shelf-life considerations. Worst candidates are things with oils (nuts, bottles of cooking oil, etc) as the oil tends to turn rancid. No way to prevent that that I know of; and it can only be moderately mitigated even in ideal storage conditions.
Canned stuff can be literally years past its marked date. Tuna, canned hams, canned things in general. I was on my own last night (wife is babysitting a family member who just had their gall bladder out at 94), so for dinner I grabbed a can of chili (wolf or hormel; not sure) that 'expired' last year. I've eaten canned hams 3-4 years past their 'use by' dates. This isn't unique to me, many others here have done likewise. Some things will eventually get mushy (fruits, vegetable soups, etc), but in good conditions that takes quite a while past the 'use by' date, and even then it's still safe & healthy for quite a while afterward.
Storage conditions are the biggest factor in shelf life. We keep our 'pantry' between 45-65 degrees and also keep the humidity in there down at 35%; at low as the dehumidifier will go. And in those conditions we're able to keep even things like boxed breakfast cereal fresh-tasting for over a year; do it all the time.
"The best a man can hope for is a chance to prove that the good lord didn't make a mistake putting him here in the first place." - Will Sonnett