I used to get cold sores all the time especially when I had candida. I am not sure if eating certain things caused it though I would get them after a big weekend out on the town. I would also get them every time we got really busy around here at work and I was stressed.
In almost 2 years I havent had one at all as I have been taking a good multivitamin an all in one oils omega 3,6 and 9 and I have zovirax on hand for times of stress and I simply put some on if I feel run down. At the time I was getting them I started supplementing lysine for a few months as well as I have heard it prevents cold sores. All this seemed to work well and is things I should be doing anyway for general health.
The coconut oil sounds good though - I have coconut oil a lot as well so that could be helping too.