I realize that this might not work for everyone, but in my case, treating vitamin deficiencies treated my eyelid spasms completely.
When I started getting the spasms, I did all the routine recommendations like getting more sleep and avoiding caffeine and sugar but it didn't work. Even my eye doctor wasn't able to do anything, he said it was due to stress and suggested more exercise.
I then went to an endocrinologist and he requested blood tests. The results showed that I had iron and and magnesium deficiency. He put me on supplements and I have not had eyelid spasms since.
I urge everyone suffering from spasms to get a check-up and make sure that they do not have vitamin deficiencies.