Which foods become shelf-stable on cooking and why?

Certain foods are normally refrigerated, but after cooking can be kept at room temperature for a few days at least. An obvious example is cheese -- e.g. cheese-topped rolls normally have a best before date a few days after they reach the shelves. Many cake ingredients have to be refrigerated, but then the resulting cake can be kept at room temperature.
How can we tell which foods undergo this change? Alternatively, what's a change -- is it just drying and water activity (it might be, given that dried hard Italian cheese is shelf-stable).
The question is about the science but the motivation is things like savoury flapjacks as appetising carb-heavy snacks for cycling, when the sweet stuff becomes unappealing. For it to be worth making a batch, they should have keeping properties on a par with biscuits (cookies/crackers), i.e. almost forever if airtight (so longer than my first example, but that's because the bread would go stale).
Pictures about "Which foods become shelf-stable on cooking and why?"



Which foods are shelf stable?
Examples of shelf-stable foodsGrains and Starchy Foods: Rice, couscous, quinoa, tortillas, pastas, crackers, cornmeal, wheat flours, along with baking powder and baking soda. Fruits andVegetables: So many varieties are canned or dried, like raisins, apricots, prunes and unsweetened applesauce.What makes food shelf stable?
Information. In order to be shelf stable, perishable food must be treated by heat and/or dried to destroy foodborne microorganisms that can cause illness or spoil food. Food can be packaged in sterile, airtight containers. All foods eventually spoil if not preserved.What is shelf life in cooking?
The shelf life of food is the period during which the food retains an acceptable quality from a safety and organoleptic point of view, and depends on four main factors, namely formulation, processing, packaging and storage conditions.Shelf Stable Cooking | How to Eat for $20 a Week
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Pixabay, Huy Phan, RODNAE Productions, RODNAE Productions