Slow release pill for tisha bav

Hi,

For someone that suffers from caffeine headaches, would it be permissible to take a slow release capsule on shabbos, it contains both caffeine and ibuprofen, that is meant to release the next day.

Is it an issue of hachana or refuah on shabbos?

Would it be better to just take on tisha b’av, on sunday?

Also can it the pill be taken with a little bit of water?

Best to take it on Tisha B’av. If they need it with water then take it on Shabbos