Caffeine has a half-life of roughly five to six hours in most adults. A coffee at four in the afternoon means a meaningful amount is still circulating at ten at night. Most people underestimate this badly, because they no longer feel stimulated.
What the evidence shows
Controlled sleep laboratory studies have measured this directly. Caffeine taken even six hours before bed measurably reduces total sleep time and disrupts sleep architecture, particularly deep sleep, and it does so in people who report no subjective difficulty falling asleep.
That last point is the important one. The absence of a feeling is not evidence of an absence of effect, and this is one of the clearest demonstrations of it.
How much difference it makes
For someone drinking coffee late in the day, moving the cutoff earlier is often the single largest available improvement to their sleep quality, and it costs nothing. It routinely outperforms the supplements and gadgets people buy instead.
Individual variation is real. Some people clear caffeine quickly and genuinely can drink an espresso after dinner. Others metabolise it slowly. Neither group can tell which they are from how alert they feel.
What to do
Set a cutoff eight to ten hours before your intended bedtime and hold it for two weeks. For a bedtime of eleven, that means nothing after one or two in the afternoon.
Remember what else contains caffeine: tea, green tea, cola, energy drinks, dark chocolate, and many pre-workout and headache products.
Cautions
Stopping abruptly causes headaches and irritability for a few days. Taper over a week if you drink a lot.
Caffeine interacts with a number of medicines, and some medicines slow its clearance considerably. Certain antibiotics, some antidepressants and some asthma medications all matter here. If you take anything regularly and caffeine seems to hit you harder than it used to, ask your pharmacist rather than assuming.
When to see a doctor
Persistent insomnia lasting more than a month, or waking unrefreshed despite adequate hours, deserves proper assessment. Sleep apnoea is common, frequently missed, and not something you fix with caffeine timing.