With regard to hilkhoth shabbath, a choleh she'ein bo sakana (one with a non-life-threatening illness) is allowed to engage in therapeutic activites, such as taking medication. This is not the case with regard to a meichush (minor discomfort) because of a Rabbinic prohibition of performing therapies on Shabbath (refuah; see Shemirath Shabbath KeHilchatha 34:1,3 cited by http://www.halachipedia.com/index.php?title=Medicine_on_Shabbat). A generally accepted criterion to distinguish between these two classes of affliction is whether one would lie down because of the illness (see Mishnah Berurah 328:121 and Rabbi Dovid Ribiat's "The 39 Melachos" vol. 2 p. 492).
Separately, we find that by fasts other than Yom Kippur, a choleh she'ein bo sakana is not obligated to fast (see Shulchan Arukh 554:4). By analogy, shouldn't this mean that anyone who would lie down because of how he feels should not be obligated to fast (and, at the very least, should be allowed to take, e.g., caffeine pills or Tylenol to reduce or preempt, e.g., a caffeine-withdrawal headache)? If not, what is the reason to distinguish between these two areas?