Is energy always conserved?

Consider a segment of blue light shifting to red light. The same energy is there, the red segment is simply lengthened. A longer duration of less energy equals a shorter duration of more energy. No loss.