A resistor should be wired in series with the capacitor.
“Snubber” Circuit
A sudden rise in voltage across the switch contact caused by the contact opening will be tempered by the capacitor’s charging action (the capacitor opposing the increase in voltage by drawing current).
The resistor limits the amount of current that the capacitor will discharge through the contact when it closes again. If the resistor were not there, the capacitor might actually make the arcing during contact closure worse than the arcing during contact opening without a capacitor!