>>40612848 (OP)Photons only go one speed. So if they gain or lose energy, it goes into their vibration. So if a photon is coming toward you over a long distance, the vibrations seem to come at a greater frequency, which makes them seem more blue than they are.
If going away, they seem to drop frequency, and shift toward red.
It's like the Doppler effect, but for light, and different in the way the vibrations compress or expand.