I just stopped nursing my daughter, and she was 26 1/2 months when we weaned. A couple of things stand out to me about your post. First, I will say that I never cut out caffeine while I was nursing either of my kids, and neither did most of the nursing moms I know. Secondly, I think you need to separate the sleep training from the nursing. If you can get him to sleep through the night, the weaning will probably be much easier. It will be hard, but you know that you have to do it. Can Dad help? Maybe have him wake up with your son when he wakes in the middle of the night?
As for actually weaning, what I did was every time my daughter asked to nurse, I asked her if she would rather have A. M&M instead. She almost always chose the M&M. I gave her exactly one, so I didn't think it was that bad. If she really insisted she wanted to nurse (usually if she was upset), I would let her. Pretty soon she was just nursing once or twice a day. I will say that I did it this way knowing that she was going on a five-day trip with her dad without me. I nursed her right before she left, and we haven't nursed since. She has asked a few times since she's been back (it's been about a month), but I just tell her that there isn't any more milk. It was much easier than I was expecting it to be.
I weaned my son at exactly 2 years. In his case, he bit me pretty hard. I made a big deal about how much it hurt and put band-aids on my nipples. I think it freaked him out so much that he didn't really want to nurse any more after that. With him, it was pretty much cold turkey.
Good luck. I was a little sad when it was over, but it is really nice to have my body back.