Those rare moments when I have managed to be happy for my lover have generally been achieved by putting myself in my lover's shoes. I know that I've had sex with other people, and come back to the relationship happier and stronger than when I left. I know that, while I was in the middle of having sex with that other person, I felt no less love (and maybe even more) for my partner. If I face my fears and try, I can get excited for her, knowing that she's probably having a good time. Loving someone means wanting them to be happy.
I think compersion starts with trusting your partner's love. Which is of course inextricably tied to your self-esteem. That's the foundation. Once you kill jealousy and insecurity, then compersion becomes possible. I don't think it's necessarily that linear, though. I find that trying to be happy for my lover often also reduces feelings of jealousy. But I think compersion is possible to the degree that you are able to slay the green dragon. Of course, that's easier for some than for others.
But confidence can be gained. Jealousy can be slain. Compersion can be achieved. I know, because I've made progress on all of these fronts. You can too.