How to drink coffee most effectively to refresh yourself? When to drink without affecting sleep?

A question related to drinking...