The compound used in percusson caps is chemical, and generally is protected from moisture by a plastic film that covers the chemical explosive. However, if the caps are allowed to stand for years in a damp environment, unprotected, water or moisture is bound to get in to the chemicals, and can change them enough to make them no longer fire. You can always try drying them in the sun on a cookie sheet to see if you can reverse the process, but I doubt it will do any good. If the compound were black powder it would do some good, but being other compounds, the moisture would cause a chemical reaction with the explosive, and neutralize it.
I have old caps my father bought back in the 1960ws that still work, but he always kept them in sealed containers with desicants in the containers to soak up any moisture that might get in. In addition to the sealed tins, the caps were wrapped in plastic bags, again with a desicant pack inside th plastic bag. Keep the caps in a dry, cool, place, and they probably can be kept indefinitely, and still work.
Don't feel bad about caps not going off> I have had matches, both stick, and paper matches that would not strike or burn after being stored in damp places for years. Its the same deal. I always check my percussion caps by giving them a visual check before putting them on my nipples. The only CCI percussion cap I have had that was a dud, was one that had no explosive in it at all.