Caffeine makes you so you can’t sleep, so you drink caffeine to compensate. Then that makes you sleep even worse, so you drink more caffeine, etc.
It has to start with a good sleep schedule/routine. I’d recommend melatonin early in the evening to get you to fall asleep earlier than normal. Avoid Tv/phone screens and such (“sleep hygiene” is the topic you’ll want to look into) to help your body be ready for sleep.
Then Tylenol/ibuprofen your way through the headaches for a few days. Use something alternative (caffeine free coke, La Croix, etc) if you need a decoy that fills the void of your normal carbonated/caffeinated beverage.
Good luck!