In the case of migraine or other forms of headache, the first advice is to take an anti-inflammatory and/or analgesic medication from the earliest warning, to nip the pain in the bud (or even anticipate it) and prevent it from amplifying and consolidating, until it becomes unbearable and difficult to counteract.
Easy said, less easy done, because the early symptoms of a headache attack are not always so clear to recognize. In the case of migraine, for example, in the hours leading up to the attack there may be fairly characteristic visual disturbances, but also an increased need to pee or craving for sweets, which very few would link to the impending headache.
A few pointers on aspects to consider
.