I'm getting this a lot as I'm just starting out. Was limping for 3 weeks from what seemed to be a permanent cramp, but I didn't want to stop riding.
I found heat helps a lot, from a hot water bottle or just wrap your foot round a mug of hot water (keep your sock on), for 5 10 minutes and the cramp will ease off surprisingly well. You can also do it before going out.
(The thread states "remedies"... for "prevention" you're apparently better getting sturdier soles )