Any exercise that can help the muscles to have more optimism while riding, or relief sore on muscle. I also accept any special massage.
I prefer light jogging or running before. If that's not possible then some light stretching would be good since it tends to warm up the muscles for more rigorous activity later on. Do not forget to hydrate enough before cycling, during the pre-workout. Even skipping ropes works if you can do that.
Afterwards, a stretching becomes mandatory to relax the muscles. Also, while you are riding long stretches and get wound up and take a small break, do stretch the legs and back a bit, it helps in the long run. This would keep muscle soreness at bay, if not avoid it completely, but at-least delay the onset of it by a significant distance eventually.
The more you practice these habits in accordance to what your body tells you, you will be able to realise which muscle is going to ache/pain next and adjust your speed, posture, pit-stop, hydration accordingly.
I get enough stretching while getting my pants on before a ride. I take the first 10 minutes fairly slowly too, because its in traffic with lights. A drink of water before you go helps with pre-hydrating.
Afterward, do a cooldown ride for the last 5-10 minutes, not too fast. A hot shower helps, followed by clean fresh clothes. Then go clean your bike.
Some people use sports massage or self-massage with a roller to beat up tense muscles.