The caps in question were generally loaded with an unstable primary explosive such as fulminate of mercury or picric acid which would detonate if struck sharply. The cap was placed on a metal priming 'nipple' immediately next to the black powder of the main charge and then, on the pull of the trigger, struck sharply by a spring loaded hammer. This normally made the cap explode, firing the round.
Caplock was a great improvement over previous designs - the system was close to weatherproof and a lot harder to mis-prime than previous designs. There were also fewer parts to go wrong and the caps generally fired pretty reliably - and could be quickly replaced if they didn't. It was relatively easy to convert many designs of flintlock to fire with caps and this was a fairly common after market mod during the transition.
The cap served the last generation of muzzle loading weapons and (appropriately enough) cap and ball revolvers but was displaced in the latter half of the 20th century by breech loading weapons firing cased ammunition. For reference, cap and ball rifles were the standard weapons of both sides at the start of the War Between the States but by the end the Union in particular had begun to issue breech loading cartridge rifles.