you really can't learn compersion in my experience. It will happen when it happens. If you understand it, recognize it and then see it whell up in you, you could always try and hold onto that feeling.
Everyone gets it differently. Its very natural for my wife, where I find it a little more difficult. Don't beat yourself up for not having it all the time, just try to figure out the reasons why
Sometimes it takes time.
Its also hard to feel compersion for a situation if you aren't secure in that relationship or the situation. It healthy to identify that and the reasons why.