When I was running track I’d get them a lot as well, usually at the most inconvenient times. I’d push through them during races, but as soon as it was over, if they hadn’t subsided, I’d just stretch them out. That was the only thing I really found effective. And like you, I avoided food (completely on meet days) and high intakes of water, just enough to keep hydrated, and continuously stretched.