Not only a mid-day cup of coffee or tea, but even a glass of cola or a chocolate doughnut contains enough caffeine to keep some people up at night. Caffeine can linger in the system for up to 15 hours, revving your nervous system and interfering with sleep. If you are a coffee drinker troubled by sleep problems, try eliminating caffeine. If you feel and sleep better after two weeks of being caffeine-free, then avoid caffeine permanently. You can try adding back one or two cups after the two-week trial, but cut back if insomnia reappears.