It doesn't exactly prevent headaches, but hydrating with lots of water can help alleviate the problem. Relaxing in a dark quiet location, massage, yoga and meditation can also be helpful.