After looking at some posts,I started wondering if using capacitors,especially electrolytic ones is as safe as I thought.After making sure that the you don't supply a bigger voltage than the rated one and checking,if you have the corresponding type,that it's polarized correctly,what else should you do to make sure it works correctly(doesn't explode or fail)?Does ripple current matter if it's not connected to AC current coming from an outlet,but there is still AC current flowing through the capacitor from a battery(low voltage and current DC transformed in low voltage and current AC)?Or is there something else I should pay attention to?
Ripple current matters- it causes heating which will reduce the life of the capacitor. Operating temperature is the main factor in determining the life of electrolytic capacitors. A capacitor rated at 85°C may only have a life of 2000 hours at that temperature. Rule of thumb is that the life doubles for every 10°C reduction in temperature, so if you wanted a 64,000 hour life (7 years operating 24/7) then you'd need to keep the capacitor cooler than 35°C. The capacitor does not care where the ripple current comes from, only the RMS current (and to a lesser extent the frequency).
Most larger capacitors are designed to vent with relatively little drama under 'normal' failure conditions. The most typical failure mode is that they dry up and the ESR increases (and internal heating usually increases as a result) until the circuit no longer functions. Under some conditions (very high fault current for the size of the capacitor) you can get it to explode but it's unusual unless deliberate.
United Chemicon supplies this application information entitled Capacitor Venting Operating Non-Solid Aluminum Electrolytic Capacitors.
Solid Tantalum electrolytic capacitors are safest when left in the parts drawer, or used only with a relatively large series resistor. Their failure modes include flames, burning and smouldering. Follow the application information directly from the manufacturer to the letter (and even then, problems are not unknown). The most important thing is to limit the current and overrate the voltage by perhaps 3:1.
Edit: To find ripple current, look in the datasheet. For example, suppose we want to use a Kemet ESK108M025AH4AA 1000uF/25V capacitor. The ripple current for this part is specified as 760mA (at 120Hz 85°C). Note that there is another part number in that series (in a larger case 13mm dia x 20 h rather than 10x20 with more surface area for cooling) that has the same voltage rating, same temperature rating and same capacitance but has a higher ripple current rating (950mA).
If your temperature is lower the permissible ripple current is higher (at a cost in life, see above), and if the frequency is higher or lower than 120Hz then the permissible ripple current is higher or lower.
For example, if you are using a half-wave rectifier at 50Hz mains, then you have to derate the 760mA to 570mA.
You can estimate the expected RMS ripple current by simulation but it's best to verify with measurement. Generally in a mains transformer filtering situation the RMS capacitor current may be 2-3x the DC load current, so in our 50Hz half-wave situation we might be able to get 190mA DC current. There's a moderate 3.8V of ripple (+/-1.9V) in that case, so the limitation might be ripple current or voltage. Stepping up to the larger capacitor or a 13 x 25 2200uF part might be called for- or add some diodes for full wave. Engineering trade-offs.
I once exploded a couple of beer can sized electrolytic capacitors and destroyed a 3-phase, 15 amp Variac by turning up the Variac too fast to raise the voltage of a DC supply that didn't have a sufficient limitation on the charging current.
Edit. The capacitors in a DC supply that is feeding an inverter will need to be sized to carry significant ripple current due to the reactive current in an inductive load supplied by the inverter.