Caffeine has a half-life of about six hours so it can affect your sleep without necessarily knowing it leading to bit of a vicious circle. If you are interested, Dr. Peter Attia has a three part episode with Dr. Matthew Walker on sleep. It changed the way I prioritize getting sleep.