Foam can be a convenient and easily and quickly applied air barrier. However, foams that become rigid when they dry are not an effective air barrier on certain substrates. This is almost always true if the substrate expands and contracts, and if the foam is applied over a substantial area. In addition, rigid foams normally will not create an air barrier if used to seal gaps between different substrates as they usually have different rates of expansion and contraction.
Fortunately, some foams remain flexible and elastic even over time. Generally, open-cell foams remain more flexible than closed-cell foams. And, even some foams which become rigid may be effective air barriers if any substrates they are in contact with do not expand or contract.