Heat the oil in the pan over a medium heat. Fry the onions until soft, about 10 minutes, stirring often, then add the garlic and chili and fry for a further two minutes. Season with a little salt.
Add all the remaining ingredients bar the gherkins and capers, and bring to a low boil. Simmer for 20-30 minutes, until it starts to thicken like a jam.
Add in the gherkins and capers, taste and season if required. Allow to cool before serving.