The first step is to determine if the cable is indeed failing. If it's just showing some wear and tear, a quick fix may do the trick. However, if one of your cables is constantly becoming damaged or failing outright, you may need to replace it.
Fix contradictions in your charging cables:
If your cables are always getting twisted, tangled and pulled apart, odds are there are contradictions present in them. This can cause small electrical shorts that can eventually lead to cable failure. To prevent this from happening, make sure all of the wires are tightly coiled in the cable itself and not lying around loose.