Caffeine is a miracle compound or it is toxic death. Oodles of research with new reports that it is great/bad/pointless on a daily basis. Have it with coconut oil and it turns you into a Greek God overnight, have a skinny latte and it makes you fat, drink it before a bath and your testicles fall off. All there is to know about the mysterious workings or otherwise of caffeine can be found at www.examine.com. I'm a cup a day kind of guy, gallons and gallons of tea otherwise. I'm a Brit with yellow teeth. Even if tea had the potential for causing instant death, I would still drink it.I could pass up the coffee but nothing will stop me drinking tea. You may be like that with coffee and if so, what the hell. Look for a third way.
There may or may not be a link to magnesium deficiency and coffee but hard training, long, long endurance and diet do affect levels. Magnesium supps are well researched too as is boosting levels with green veg and nuts. Also, may be an old wives tale but having a bath soaking in epsom salts are considered a good way to get a dose. Relaxing anyway. Then have a nice cup of tea.