In 2015, archaeologists reported that they'd found 3,000-year-old honey while excavating tombs in Egypt, and it was perfectly edible. This durability is thanks to the unique features of honey: it is low in water and high in sugar, so bacteria cannot grow on it. Honey also contains small amounts of hydrogen peroxide, which inhibits growth of microbes. This is partly why bees produce it for the young in their hives -- it is both food and protection.
Processing honey also helps as the sugars in honey are hygroscopic and tend to draw in atmospheric water, which is not ideal. However, during processing and packaging, the heat treatment first removes water and then airtight lids keeps the water out, helping it keep for longer. Although honey can go cloudy and crystallise when opened as the sugars draw in water again, this physical change can be reversed by simply warming the honey.
2. Dried legumes
As with honey, the key to a long shelf-life is processing and storage. Drying beans, lentils, and other legumes increases the sugar concentration and lowers their water content, which makes it hard for bacteria and moulds to grow on them. Also, any enzymes that would naturally break down the product after harvest are put into suspended animation. If the container is airtight, they will last for years and still be a great source of protein. If you allow water in, however, then they will only last a few months.
3. Soy sauce
Soy sauce has the potential to last at least three years. The combination of its salt content and being fermented means that, if it is unopened, it should have a very long shelf life. How long it will last depends on the type of soy sauce and, once opened, the temperature it is stored at. If it does go off, it is likely to be due to mould growing around the lid.
Some may argue vinegar is in fact already spoiled wineor cider. But its acidic nature, traditionally achieved using Acetobacter bacteria to ferment it, means other bacteria struggle to grow in it, and so it can last a very long time. While white vinegar will remain almost unchanged indefinitely, other vinegars may change colour or produce a sediment. Typically, this will not affect the safety of the product, just the appearance and perhaps flavour.
5. White rice
White rice has been eaten after being stored for 30 years in tins, with the parboiled rice then passing a tasting panel test. What appears to be key for rice is atmosphere and temperature. Studies have reported that a low temperature (about 3℃) and a lack of oxygen appear to be important for its longevity. Brown rice, although often considered to be healthier, has a shorter shelf life. Its fibrous bran contains unsaturated fats, which can turn rancid. So if your brown rice is oily and smells like old paint, it's best to throw it away.
6. Dark chocolate
There is some debate about whether chocolate goes bad. The addition of milk to chocolate may reduce its shelf life. But dark chocolate appears to last better, despite not always looking like it has. This could be because, if it is not stored at a constant temperature, the fat can rise to the surface, leaving a bloom that looks a bit like mould. If stored at a constant temperature, however, chocolate can last for two years or more, with concentrations of the compounds which some link to health benefits remaining throughout this time. For most people, though, chocolate does not tend to last this long before it is eaten.
7 & 8. Sugar and salt
Many of the foods that last for a long time are high in sugar and salt. In simple terms, they draw water out, so if bacteria try to grow on it, they will simply shrivel up. This is why we use salt to make ham, sugar to make jam, and both to make gravlax.
As foods in their own right, if salt and sugar are stored away from moisture in airtight containers, they will last indefinitely. But additives, such as iodine added to salt, can reduce its shelf life to about five years.
Of course, most foods don't last very long. This is because they contain the things microbes love, such as nutrients and water, and not much of the stuff they don't love, such as salt and acid.
Be aware that use-by dates are generally used for food safety reasons, and best-before dates are more to do with the quality of the product. The best-before date might have little bearing on the shelf life of some products, only how it looks or tastes.