The below by Joe Friel is a great one, below is a summary but feel free to check out his blog about cramping
1) train for the event you are racing ... often it's the over exertion late in the race that causes the cramps, this is why less cramps are reported in late season.
2) electrolytes are important but need not be consumed excessively (likely enough in a quality drink) ... this will be personal based on sweat rate and type of race / intensity
3) posture on the bike (flat back / rotated pelvis ) is important practice this and refine bike fit to ensure it is possible / comfortable
4) stretch especially hip flexors (to prevent forward tilt of pelvis, which can cause stretch on posterior leg muscles)
5) Remember to fuel ride appropriately with water and carbohydrate to prevent excessive protein utilization / ammonia build up
( 17-25 oz / hr depending on heat and body size and exertion + 200-300 kcal depending on body size ... EVERY RIDE so you are used to it
Be sure to look critically at your practices before reaching for the salt block !
Steve and Peter