Which coolant did you use, the OEM fill for decades now has been long life OAT / HOAT (organic acid technology or more recently hybrid organic acid technology ) which is why it now lasts 10 years instead of 2 years. Maybe a previous owner used stop leak or some other chemical that has reacted with new coolant. It is the corrosion inhibitors that get worn out, not so much the ethylene Glycol ( anti-freeze ) part ( the OAT refers to the inhibitors, the anti freeze is still Glycol, which is colourless ).
The foam may just have been trapped air that had been compressed by being heated up bubbling out ( like taking the top off a aerated drink bottle ) - it is dangerous to remove rad cap when engine is warm as compressed air and hot coolant can cause it to erupt out of the filler cap hole.
one of the many 'coolant' threads on this forum
https://clubjazz.org/forum/index.php?topic=9163.msg48651#msg48651This is the ready mixed coolant I have used in the past - it is already mixed to 50% with distilled water, which is the ideal ratio, do not use a silicate based one in modern engines.
https://www.halfords.com/motoring/engine-oils-fluids/antifreeze/halfords-oat-ready-mixed-antifreeze-5-litresDon't be fooled by the different colours of coolant - they are all Glycol based and the colour is added to show up any leaks better. I know silicate based ones designed for older engines can cause problems in newer systems, mainly because they are abrasive and can cause premature wear on water pump impeller and seals - the OAT ones are much better and where silicate ones have to be changed every two years ( the silicate starts to cause problems ) the aftermarket OAT based ones are good for 5 or more.