In my personal experience, I've got so much better after quitting drinking coffee. I used to drink only 2 cups a day, way before my bedtime, however, it still affected at night. So if you are a coffee lover, I recommend switching to tea.
coffee make you awake so it is better to avoid if you need a good sleep