Caffeine is the most widely used stimulant on earth and the arithmetic of how long it lasts is simple enough to do in your head, which makes it worth doing once properly.
The half-life maths
A half-life of five to six hours means the dose halves in that window, then halves again, and so on. For a 200mg dose, roughly a large coffee, taken at 2pm:
8pm: about 100mg remaining, comparable to a fresh espresso.
2am: about 50mg remaining, comparable to a cup of tea, circulating while you are meant to be in your deepest sleep.
8am: about 25mg, which is why habitual drinkers never quite start from zero.
Written out like that, the standard advice to stop by early afternoon stops sounding puritanical and starts sounding like arithmetic.
The part people get wrong
The most common objection is “caffeine does not affect me, I can drink an espresso and fall straight asleep.” That may well be true, and it is not the relevant test.
Caffeine works by blocking adenosine receptors. Adenosine accumulates through your waking hours and is the substance that produces sleep pressure. Blocking it does not just make it harder to fall asleep, it reduces the depth and restorative quality of the sleep you do get.
The measurable consequence is reduced deep sleep and reduced total sleep time, in people who report no difficulty at all with sleep onset. Sleep onset is the one part of the picture that is most obvious to you and least representative of the whole.
Why your cutoff is not the same as anyone else’s
Caffeine is metabolised primarily by the CYP1A2 enzyme, and genetic variation in it means clearance rates differ substantially between people. Fast metabolisers genuinely can drink coffee at 6pm without much consequence. Slow metabolisers genuinely cannot drink it at lunchtime.
Other things that shift the rate: some oral contraceptives and other medications slow it considerably, pregnancy slows it a great deal, smoking speeds it up, and habitual heavy intake produces tolerance to the alerting effect without removing the effect on sleep architecture.
Which means the honest advice is not a number. It is a method.
How to find your own cutoff
Pick a candidate cutoff, say 2pm, and hold it for two weeks. Then move it two hours later and hold that for two weeks. Compare your sleep duration, interruptions and overnight physiology between the blocks rather than between individual nights.
Two weeks per condition is not arbitrary. Single nights are far too noisy for a change this size to be visible, and anything shorter will mostly measure whatever else happened that week.
Keep the dose and the timing of everything else as stable as you can, and in particular do not run this test across a period where you are also drinking more than usual, since alcohol will swamp it entirely.
For the substance with the larger and more reliable overnight effect, see how long alcohol affects your HRV and sleep.