The free drinks and snacks recall the golden years of 20th-century aviation, when flying retained a dash of glamour

You can’t taste the food properly, it has the same texture as the in-flight magazine, and even the tea is boiled at the wrong temperature...

Patients, prisoners and passengers have much in common. No one wants to be in a hospital ward, a jail cell or an airline seat; we yearn to escape. During our confinement we enjoy no great expectations about the quality of the food, which is usually just as well.

Remember your last great airline meal? Neither do I. Given that the air pressure in the average jet during the cruise is set at between 7,000ft and 8,000ft, flying has little chance of being a great gastronomic experience. "It's very difficult to maintain appetite at high altitude," says Richard Pullan, director of altitude-training specialist the Altitude Centre in London. "The senses of smell and taste are greatly inhibited."

Equally inhibited are airlines' options for feeding passengers. They are constrained by budgets, the need to cater for the lowest dietary denominator, the lack of galley space and the fact that water boils at below 80C, making even a decent cup of tea a nigh-impossible challenge.

No one expects free meals as they travel in the cheap seats on other forms of transport, such as trains and ferries. So why do airlines bother? The answer depends upon who you ask.

One strong motivation among the "legacy" carriers is heritage. National airlines from Alitalia to British Airways like to distinguish themselves from budget competition by providing complimentary catering. The free drinks and snacks perhaps also recall the golden years of 20th-century aviation – from the airlines' point of view – when fares were sky-high and flying retained a dash of glamour.

The concept of in-flight catering took hold partly because fares were fixed by international agreements. With discounting prohibited, one way to distinguish an airline was to offer superior meals – though the trade body, IATA, policed points of difference and even ruled on the maximum dimensions of a salt cellar to ensure no carrier won too sharp an edge on what can only very loosely be described as "the competition".

Eating a meal also helps break up the tedium of flying long distances. Currently, the world's longest flights – Sydney to Dallas on Qantas, Atlanta to Johannesburg on Delta – are operated by last-generation jets. And at 15 hours-plus, chicken, fish or steak takes on some appeal even if its taste and texture is difficult to distinguish from the in-flight magazine, and despite its utter disconnection from the land and sea over which you are passing at 500 knots.

At the other end of the spectrum – on UK domestic flights – you might be forgiven for thinking food wars have long given way to fare wars. No longer does British Midland compete egg-to-egg with British Airways to Belfast, Edinburgh and Glasgow from Heathrow; the latter devoured the former two years ago. Yet breakfast is still sacrosanct to BA, which serves at least a hot bacon roll or similar to everyone who boards a domestic flight due to depart before 9.30am. Passengers evidently still value the first meal of the day – perhaps because they've been up since 4am.

Even Ryanair is about to get in on the act. "Catering is getting much more sophisticated," says Michael O'Leary of Europe's biggest budget airline. The previous day, the CEO had been testing a new cooked breakfast – "Sausages, rashers, it's amazing stuff that cooks in the oven." You will soon be able to get an in-flight "full Irish" on the dawn flight to Dublin – at a price, of course. "About a fiver," estimates O'Leary.

The notion of paying for in-flight grub on short-haul flights is firmly ingrained – yet 20 years ago the practice was unknown. When easyJet launched in 1995, one of the infant airline's many challenges was to persuade a dubious travelling public that it was perfectly reasonable to charge £1 for a cup of tea and significantly more for a sandwich. To the delight of budget-airline accountants, in-flight catering switched magically from a cost to a revenue stream.

Rationally, selling food makes far more sense than giving everyone the same portion-controlled tray. It means that if you sensibly plan to dine after you touch down in Nice, you are not paying for something you don't want.

On-demand catering dramatically cuts down waste, too. As with cruise ships, airlines can spend a fortune creating meals for passengers, then a slightly smaller one disposing of all the uneaten food. In premium classes, some airlines have a policy of "100 per cent loading" – meaning that if there are 50 passengers in the business cabin, 50 of each of the main courses will be prepared to eliminate the chance that a high-spending traveller should fail to get their first choice.

The shrewd premium passenger on an overnight flight, though, might opt for pre-flight dining: book a first-class seat from Heathrow for a flight after 8pm and you qualify for a waiter-service dinner in the lounge before take-off. An alternative course is taken by BA's partner Iberia. The Spanish airline claims to offer "the only eight-star restaurant in the world" in Business Plus, after enrolling four chefs – each with two Michelin stars – to create high-altitude haute cuisine Mediterranée at 35,000ft. Atlantic queen hake with saffron sauce and quinoa stew, anyone?

Back in the cheap seats, KLM Royal Dutch Airlines is doing its best to limit waste and improve taste with an "à la carte" offering for economy passengers: pay €14 and you can upgrade your dinner, if not your seat, with a choice of premium meals from sushi to a "full Indonesian" – an elaborate rijsttaffel (literally, rice table).

So what is the best strategy for your next flight? Without a doubt, self-catering. As long as you stay the right side of the "liquids" line (which rules out yoghurt or mayonnaise in quantities over 100ml), a pre-flight trip along your high street – or to the nearest supermarket – can elevate you to the envy of your fellow passengers. The key is freshness: bread, fruit, munchable vegetables and some combination of cheese, cooked meats and smoked fish. Your neighbour might not thank you, but your digestion certainly will: you can eat well, when you wish. Add in some good in-flight entertainment and any journey becomes bearable.

As Tim Clark, president of Emirates, told The Wall Street Journal: "With food and TV, people are mesmerised."