Hi. I would suggest carefully examining your cable at both ends where the cable connects with the USB Plug and other side where the cable connects to the Apple port. Making sure that there are no breaks in the insulation or any wires showing at all. It just may be an issue of replacing the apple cable, which you can order and easily have shipped to you.
Frayed connections on either ends can happen if someone trips over connected power cable and it gets yanked while still connected to ipad for example.
Another thing may be just simply doing as Diavonex suggested. And trying a different outlet. I would add trying a different outlet that is on a different circuit then the one you are currently using.
Only other possibilities besides a frayed cable, or a bad wall outlet, would be don't plug your adapter into some thin household extension cord with the three outlets on its far end as an extension point.
And possibly check for dirt in the adapter USB port side and corrosion on the adapters electric prongs. Also check your cable connectors for same kind've dirt and corrosion. Especially for gritty type dust that may have gotten into your connection points. Considering that you seem to be experiencing an intermittent power connection, I would really suggest checking and possibly cleaning very gently and carefully your adapters USB port, and your cables USB plug, which is where it seems you are having your connectivity issues.
if you experience this again i suggest just ordering a complete new Apple adapter and a new Apple cable. It is easier then cleaning the ports.
Lastly, How good is the quality of the electricity that your electric company provides? Any other troubles with other appliances or TV's, etc? It's only a tiny and slight chance but if you are experiencing other electrical intermittent problems then it may be remotely possible that the quality of electricity you are receiving from your provider is rather poor and that is responsible for your problems with your adapter.
Hope some of this helps you! Cheers!