I'm 173 cm with about 45 kg weight (underweight). In the same ride of 30 km with short but steep uphill and downhill, if I drink coffee I tend to feel better when riding, but about two hours after the ride I would feel weak and shaking. Note that I drink about 150 ml moccachino. I don't feel like this if I don't drink coffee. Is there an explanation to this? Am I maybe intolerance of coffee? Maybe I don't eat enough? Personally I don't really enjoy the taste of anything other than moccachino.
A recent documentary on the BBC in UK covered some aspects of ingesting caffeine prior to exercise. A written summary is here:
Without reviewing the science in detail, it basically suggests that for endurance type activities, caffeine blocks receptors in the body, leading the brain to "perceive" less pain and fatigue, allowing someone to exercise longer. The article states an optimum amount of caffeine to be 3mg per kilo of bodyweight (somewhere between 1 and 2 large cups of filter coffee for average man / woman). To experience the benefit you should drink the coffee approximately one hour before starting the activity, and the effect will last for "a few hours". If you regularly drink a lot of coffee (or take other sources of caffeine), it is likely the impact will be reduced.
Your experience may just be the effect of the coffee / caffeine wearing off, plus any lessened impact due to the amount of caffeine you ingest on a daily basis.
Of course, other factors may be causing your fatigue, but your question specifically asked about effects of coffee / caffeine.
2 hours is about how long your body has glycogen stores for. So you're bonking because your body has used all the available glycogen.
The caffeine will be making fats easier to process instead of glycogen, theoretically leaving you with more "on-tap" at the end of your ride. But you are a scrawny wee twig and lacking in mass, so for you there is less fat available, and the bonk wall will be steep and and immediate, a figurative wall.
Your solution is to eat more while riding. Start with a gel every ~30 minutes and see how you feel at the 2 hour mark. Gels are basically easily-digested sugar slop with some flavour.
If you don't like gels, then try a square of chocolate. Break it up and freeze it overnight, and store it in a top tube bag or somewhere else not directly on your person. Chocolate is also a significant component of your drink, making it a good substitute that can go with you on the bike.
A moccachino is 2/3 cocoa and milk, with an espresso shot, topped with milk foam and dusted with powdered chocolate and optional chocolate syrup.