Compressors are specialized amplifiers used to reduce dynamic range - the span between the softest and loudest sounds. The use of compressors can make recordings and live mixes sound more polished by controlling maximum levels and maintaining higher average loudness. Additionally, many compressors will have a signature sound that can be used to inject wonderful coloration and tone into otherwise lifeless tracks. 
However, compressors are often misunderstood, and over-compressing music can really squeeze the life out of it. Hence a good understanding of compression is essential for quality music production.
- Threshold - The signal volume (in dB) that triggers when the compressor is activated. Any signal over this threshold with be reduced by the ratio.
- Ratio - Determines how much to reduce the volume over the threshold (a 4:1 ratio will leave 1/4 of the volume intact and will eliminate the other 3/4 of the volume).
- Soft Knee - The compressor "knee" turns the threshold from a hard line to a soft range. In other words, it allows the compressor to gradually apply the compression instead of applying it all at once above the threshold. Higher values cause compression to begin more gradually as the threshold is approached.
- Attack - The amount of time (in ms) that it take for the compression to be fully applied after a signal crosses above the threshold.
- Release - The amount of time (in ms) that it takes for the compression to return to 0 after a signal crosses below the threshold.
- Makeup Gain - Adds gain to the output signal (including both the compressed and uncompressed portions).
Setting the compression ratio
- 1:1 - No compression.
- 2:1 - 3:1 - Mild compression
- Often used for "gluing" two related sounds together (e.g. bass/kick)
- Common ratio for compressing the master channel
- 3:1 - 5:1 - Moderate compression
- Use to significantly alter the dynamic range of a sound
- Used on drums and other percussive elements
- 5:1 - 12:1 - Strong compression
- "Flattens" the dynamic range of a sound
- May be useful for vocals
- Can be used to bring an 808 to commercial loudness
- 12:1 - inf:1 - Limiting
- Ensures that a signal does not exceed the amplitude of the threshold
- Used on the master channel
Setting attack and release
Start with the attack set to its slowest/highest setting and the release set to its fastest/lowest setting. This allows all transients through and shuts off the compressor immediately when the signal crosses back down over the threshold. From there, you can gradually shift the parameters deliberately to your liking. [Note: if your compression plugin allows you, consider setting this as the default for new instances of the device]
Set the release time to be no longer than the most common interval between transients (usually between 50-150ms). This allows the compressor to fully shut off by the time the next hit triggers it and creates a more musical effect, similar to synchronizing a delay time. 
Avoiding audible compression artifacts
A good rule of thumb for compression is to not allow it to make audible artifacts in your audio. When the gain reduction is noticeably jagged, you may ease off the threshold or ratio, but it might also make sense to increase the knee control. 
Parallel compression combines the dynamics of well-recorded audio with the effects of heavy compression, and is achieved by combining highly compressed and uncompressed signals in parallel, often in a 50-50 ratio.
One way to use parallel compression is to send an uncompressed signal to a compression buss that has a high ratio and low threshold. Then, send some of this compressed signal to the master channel along with the uncompressed signal.
Another way to ouse parallel compression - which is often simpler - is to use the dry/wet knob on the compressor device (if available). The compressor is again set with a high ratio and low threshold, but the dry/wet knob is set to around 50%.
"Sidechaining" is a common technique that is used to create a "pulsing" sound in one or more signals. This can be accomplished by using an external signal to trigger compression on a separate signal. This is in contrast to a regular compressor, which acts on itself according to its own volume over time.
A common sidechain technique is to use a kick drum as the trigger to reduce another signal (for example a synth or a bass). To do this, set the external/sidechain source for the compressor to the kick, and reduce the attack very low. Make sure that the low attack doesn't create a "clicking" sound. If it does, you can usually raise it just a little bit to remove the click. Then, adjust the release time to determine how long the pulsing sounds last. Many compression plugins contain visual interfaces to help the user visualize this process.
EQ the sidechain signal
Many compressors allow you to apply an EQ to the external sidechain signal. If you are using a kick drum, or another signal with a strong bass component, it is usually a good idea to cut the low end, which has a longer release time than the high end. This can make your compressed signal come in and out more smoothly. It will also allow you to more easily control the compression using the attack and release parameters.
Sidechaining to a "ghost"
Instead of sidechaining a signal to another audible element in a song (such as a kick drum), you can set up a "ghost" signal that activated the sidechain instead. To do this, simply add a new "ghost" track and set it as the external sidechain source for your signal. In that new track, create a clip that plays a sound that corresponds with how you want to reduce the signal in the compressed track. Then mute it. This way, the sidechained signal will react to the ghost track but the ghost track itself will be muted. It is common to use a hi hat for a ghost track, or something else with a short attack and fast release.
Using a ghost track introduces the freedom to create new and interesting rhythms in your sidechained signal that may not exist elsewhere in the song.