Spray foam is pretty expensive per r-value. Rigid foam is much better--if you have the room for it. Neither should really be exposed to sunlight, and the rigid foam is easier to cover with something like drywall. Either can be painted to prevent UV damage.
For example, Tiger Foam (available to the do-it-yourself person) costs 13 dollars per cubic foot, not counting labor and wasted product.
2" pink foamboard (like Dow Fomular) works out to $4.55 per cubic foot, not counting labor and wasted product. Tiger foam does not give you triple the insulating power per dollar spent.
As noted, the glazing is the giant heat loser. Triple layer polycarbonate is not terrible....
A very useful google search:
movable thermal insulation for greenhouses
You can have your cake and eat it too.
I found Jerome's book to be very informative with regards to heating a greenhouse in a cold climate:
https://www.amazon.com/Forest-Garden-Greenhouse-Design-Permaculture/dp/1603584269
He insulates the ground under the greenhouse from the rest of the ground, and uses it as a heat and humidity battery.
The phase change of the water going into and out of the ground "battery" improves the thermal efficiency of the storage as well as helping to regulate the humidity.
He makes it work at a fairly high elevation in Colorado and has a number of commercial consult success stories too.