.............
If it was myself with cancer, I'd try not to tell anybody. The last thing I'd want in my life is a bunch of people pitying me before I expire.
If it's someone else's problem, it'd depend strongly on their individual context. I'd likely err on the side of telling them sooner than later, since time tends to add more drama.