I used to cramp a lot, either during rides or the evening after. Brutally painful debilitating cramps that would leave me sore for days.
Then I started randonneuring. Insane miles, sometimes on back to back (to back) days. Riding at least one ride of at least 200 km every month. Now I rarely get cramps. Maybe I've learned to hydrate better, but the big change is far far better fitness. If I do cramp now, it's inevitably associated with an unusually climby ride.