A flask or a thermos keeps hot liquids hot and cold liquids cold. In other words, a flask retains the temperature of the liquid that is kept inside the thermos. The basic principle behind the working of a flask is to insulate the substance from the outside air so that no heat transfer takes place. When there is no heat transfer, the temperature of the substance remains the same. Hence there is a need to use insulators inside the thermos.
Both foam and vacuum are good insulators. Though 100% vacuum cannot be achieved, anything achieved quite close to it proves useful. This is because vacuum indicates lack of atoms. Lack of atoms indicates no heat loss due to conduction or convection.
The walls of the flask are designed in such a way to limit the transfer of energy to the outside atmosphere. Inside the thermos, there is glass. There is vacuum around the glass. Since glass is very fragile, it is kept within a plastic or metal case. Since glass reflects infrared radiations, it could cause some heat transfer. That is why the glass is silvered. This is done in order to prevent any infrared radiations. Thus the flask is able to retain the original temperature of the substance that is kept inside for a constant period of time.