Cured spray foam does not settle, sag, or break down indoors, so in a dry attic, wall, or rim joist it lasts as long as the framing it is stuck to. What shortens it: sunlight, trapped water, pests, remodeling damage, and a bad mix on install day.
More detail
Spray polyurethane foam cures into a thermoset plastic bonded to whatever it touches, and that is why it ages differently from loose insulation. Ohio's residential code makes installers credit blown cellulose and fiberglass at their settled R-value, because loose fill compacts over time; spray foam has no settled value because nothing in it is loose. Closed-cell foam does drift slightly as its blowing agent slowly trades places with air, which is why credible data sheets publish an aged R-value, so compare aged numbers rather than a fresh-from-the-gun figure. In a Greater Cincinnati house the ways foam fails are practical rather than chemical. Roof leaks at old valleys, chimney flashing, and skylights are the main one: closed-cell on a roof deck will not rot, but it can hide a slow leak that keeps the sheathing wet, so look at the deck after hard rains for the first year and tell any roofer the deck is foamed before a tear-off (see the shingle warranty question). Open-cell takes on liquid water like a sponge and has to dry out or be cut away after a leak. Sunlight breaks down exposed foam, so foam left open at a pole barn eave or a garage door header needs a coating. Mice and squirrels tear at open-cell for nesting when an outside gap lets them in (more in the rodent FAQ). Electricians and remodelers who cut through foam leave holes that need patching. And foam sprayed off-ratio, too thick in one pass, or onto a cold or wet surface can shrink, crack, or stay soft; that shows up in the first weeks, which is why the certification Ohio's code requires from the installer (installed thickness and R-value for each area) and a walkthrough after the job matter. Paper warranties are separate from all of this: the manufacturer covers the material, the installer covers the workmanship, and the terms differ, so get both in writing. For the full list of what shortens foam's life and a yearly check you can do yourself, read how long spray foam lasts; for where the denser product earns its price, see closed-cell spray foam.