Timing of my caffeine is also critical. I usually try to have caffeine (2 shot Americano) in the morning and something towards the end of my work day around 3, maybe a single Americano or some sugar free energy drink. Then by the time I workout and get home I have a nice, sustainable stream of energy and can focus. I run into problems with caffeine if I have it too close to the time I really need to work. I get jittery and can't focus.
I also don't put too much pressure on myself. Some days I'll feel like working and get a lot accomplished. Other days I don't, or can't be productive later in the day, that's just life. No reason to beat myself up over it.