Without knowing more about your use case it’s a bit hard to give well-grounded advice but two considerations:
- Why not use Fusion to generate the random value
- Instead of disabling the content cache, chaning its lifetime to a couple of minutes/hours might be enough in your case. See [SOLVED] Fluid Random Image for an example