I've had boxes of emergency rations (add hot water to get some rice meal) in our house, but they usually just advertise lasting for just a few years.
For dry / packaged goods (dried beans, lentils, pasta, rice, spices, toast, etc) you can basically ignore the best-before date. Sugar (or -syrups, honey) & salt keep indefinitely.
'Wet' stuff, as long as sealed hermetically (like canned goods, shelf-stable drinks etc): similar. Seal broken: all bets are off. Use eyes / nose / texture as indicator, or don't risk it.
Long storage of these isn't a safe-to-eat, but a quality issue. Taste, sometimes texture, and vitamin / nutritional value deteriorates over time. 'Wet' stuff generally faster. Up to a point where you're left with tasteless calories with 0 vitamin content (but still safe to eat!).
Also: say you have 5y worth of food stored. Then you'd need to replace that vast amount of food semi-regularly (like use 1y worth, give away & replace the rest), which is very costly. Or consume everything yourself (FIFO). In which case a 5y's worth store would mean eating -on average- 5y old food. Not to mention the cost/waste if that supply is somehow lost (flooding, housefire, bugs, rodents, whatever).
Imho a 1 month up to 1 or 2y supply is a better compromise. Modest space/$ investment & most stuffs can be eaten within their BB date. But enough for peace of mind or ride out a wave of economic / social mayhem. Add some vitamin pills if you're worried about fresh fruits/veggies remaining available.
I've grown my own food at times. And imho substinence farming is underrated. But as a hedge against catastrophy? No. Do it for fun, do it if you have a large garden & like your independence. Or prefer the organic-everything & knowing where your food comes from.
Otherwise just buy food in bulk & stuff it in cellar (or wherever).
I got some potatoes from the local market, from a region that traditionally is planting a lot of them. These were the best potatoes I had in a long time. They were more yellow in color, much denser and tastier.
I also got some tomatoes that were quite big, softer meat and very good taste. These kinds of tomatoes can not be sold in big retail chains because they are easily damaged by transport (soft skin).
I saw a documentary about seeds. A french lady was beeing harassed by different french institutions because she was mailing traditional plant seeds to people. In Romania there are still people that use their own seeds but we also have people buying the same seeds that comercial farmers use. In this case the produce will taste more or less the same like the ones from the big stores.
PS: I forgot to mention, my potatoes had deep "eyes" (roots) inside them. This means that they can not be peeled with a machine in a factory. They are not comercially viable.
I think it's really awesome for people to grow their own food but at the same time we need to have our eyes open - industrial ag is the backbone of our civilization, our way of life, and our freedom to do anything else with our time is dependent on it.
There are home gardeners out there who tout how much of their food they grow but curiously never seem to address that the bulk of their calories come from your industrial staple grains and starches.