Liquid foams are unstable due to aging processes such as drainage, coalescence or coarsening. Since these processes modify the foam structure, they can be a severe limitation to the elaboration of solid foams with controlled structures inherited from their liquid precursors. Such applications call for a thorough understanding of foam stabilization. Here we study how coarsening can be inhibited by the combined effects of a mixture of gas containing a species insoluble in the foaming solution and of gelation of the foaming solution. We present experiments with model ordered liquid foams and hydrogel foams. They allow us to identify the underlying physical mechanisms of stabilization and their governing parameters, namely the bubble radius R, the foam shear modulus G and the number η of insoluble trapped gas molecules per bubble. We propose a scaling model that predicts the stability diagram of an ideal monodisperse perfectly ordered foam as a function of R, G and η, in qualitative agreement with our data. We show that the domain of stable foams is governed by a characteristic elasto-capillary radius set by the ratio of surface tension to storage modulus.