I've suffered from insomnia for most of the last ten years, until I made adjustments to my life:
1) Basically, for me, I found that if I sleep more than 8 hours per day, I would have trouble sleeping the next day, dragging all the way till 3 - 5 am before sleeping. To cope with this, I now force myself to sleep for only 7 - 8 hours per day, typically 7 hours and 30 mins. Without a good alarm, I used to sleep till 9 hours, which is not good for the next day.
2) Even if I can't sleep, I force myself to wake up at the same time. Let's say if I cannot sleep for the entire night, which is rare, but it does happen, I will take only a 30 min nap for the next day, and persevere till the next, staying up purposely to sleep only at around 11:45 pm every night.
3) Once in a while, I take a very slight dose of melatonin at 4:30 pm (2 sprays - around 0.3 mg) to re-align my sleep cycles since I have a little bit of delayed phase sleep disorder.
4) Avoid coffee or other stimulants like chocolate or instant noodles before bed.
5) If I cannot sleep even after 30 mins, I just get up to do something else, like read, watch TV (with a special sunglasses that filters out blue light, played at low volume to avoid stimulation), or write my novels or books, until I can sleep again. Generally, even if I sleep at say 5 am, I force myself to wake up at 7:45 am, so that my sleep cycle disruption doesn't carry over to the next day. I used to be frustrated over this in the past, but I realised that if I sleep badly for one day, I would sleep very soundly in the next, so I comfort myself with this optimism.
6) If I am watching TV or using computers at night, I use a blue light filter software or sunglasses, as blue light delays the sleep cycle.
7) Drink coffee and chocolate only early in the morning, or early afternoon. Do not do it after mid-day.
8) Also, try to clear all worries before sleep, so that one will not worry too much while trying to sleep.
9) Once in a while (at most once per week), if I cannot sleep, I may take a very small dose of Xanax to sleep. I generally try to avoid this unless needed for a special occasion the next day, as Xanax can be addictive. Taking it in the low 0.5mg dose works. I try not to do this if there is nothing important the next day.
10) I sleep using a special silk blanket bought from China that allows air to ventilate with the air conditioner on. This avoids me waking up when it gets too hot, just to take off the blankets and repeat the cycle.
11) I stop playing computer games 3 hours before sleep, or engage in any intense activity before sleep.