Caffeine shampoos are marketed as if a cup of coffee and a bottle of lotion were the same experiment. Laboratory work has looked at caffeine on follicles in a dish. That is not the same as a man washing his hair three times a week and keeping a Norwood pattern at bay.
Drinking coffee has not been shown to cause male pattern baldness. Quitting coffee will not restore a hairline. A caffeine shampoo is, at best, a cosmetic product with a mild claim. It is not a reason to delay a proper assessment if the loss is progressing.
If you enjoy the shampoo, use it. Do not budget it as treatment. The treatments that change the course of pattern loss are medical, and the treatment that replaces hair which has gone is surgical. Both deserve a clearer conversation than a supermarket shelf.