That's true of some coffee stains. That means there's a fat content in the stain. Sugar when warmed carmelizes and turns yellow. Spray 'n Wash. Then wash it with detergent. That will work 50 percent of the time.
Spills are even more of a problem if the product contains a dye.
Orange drink, for example. It contains a food dye which may color your carpet fibers. Barndt advises covering the stain with a paste made by combining baking soda and water. Then pour a solution of vinegar and water on top of it. The whole thing will start bubbling up.