How Do Hydraulic Brakes Work?
Hydraulic brakes work by amplifying the force applied at the master cylinder and thus providing superior stoping power when compared to cable brakes. This works by using a small diameter master cylinder and a larger diameter slave cylinder, as can be seen in Figure 1. The smaller diameter master cylinder allows for a high system pressure to be generated, where the larger dimeter slave cylinder then effectively amplifies the force due to the difference in surface area. Force = Area x Pressure.
Like with all things in this world, it's not possible to get anything for free! One of the compromises is that the slave cylinder will not move as far, Work Done = Force x Distance and it is only possible to get out what is put in, less frictional losses etc. 
Hydraulic fluid can be considered as being incompressible at the pressures it is exposed to in hydraulic system applications. This characteristic is what gives the nice responsive feel associated with hydraulic brakes.
As can be seen in the simplified diagram Figure 2, hydraulic brake systems consist of; a master cylinder, reservoir, brake hose/pipe and the slave cylinders.
The reservoir is responsible for coping with minor leaks, the extension of the slave cylinders as the brake pads wear and also provide a space for the brake fluid to expand into when the fluid temperature increases.
Modern mountain bike brakes commonly have 4 cylinders, however 2 and 6 cylinder configurations are also available. An increase in the number of cylinders essentially multiplies the surface area of the slave cylinder and, therefore, the force that can be applied to the disc relative to the force applied master cylinder.
Why Do I Need To Bleed My Brakes?
The rubber/plastic that components such as seals and the brake hoses are manufactured from allow the migration of atoms/compounds through its macro structure, thus, contaminants (such as water) can find their way into the brake fluid. This can detrimentally effect the properties of the fluid.
Having water in your brake fluid is bad news as it can lower the boiling point of the brake fluid. This is a problem because during use a lot of heat is generated from the friction of the brake pads against the brake disc, some of this heat manifests in the brake calliper and, therefore, heats the brake fluid within. If the boiling point of the brake fluid is surpassed then the brake fluid can boil within the system causing cavitation. The cavities of gas (vaporised brake fluid/water) are compressible and, thus, will make the brakes feel spongey and will reduce effectivity of the brakes. This is not something you want mid way down a trail! , , , , .
How Do I Know When To Bleed My Brakes?
Sponginess of the brake lever is normally an indicator that a hydraulic brake system requires bleeding. The brake lever may feel spongey before riding, which could be an indicator that there is air in the system, however, the brake lever may feel firm until a period of sustained breaking, this could be an indicator of water contamination within the system.
In the ideal world brake fluid should be changed at regular intervals, sponginess of the brake lever can lead to a dangerous occurrence, especially when unexpected. As explained previously, water ingress to DOT brake fluid is not dependant on how much you ride the bike, it is the migration of water through the rubber/plastic based elements of the hydraulic brake system over time. . Normally it is recommended that you change brake fluid in automotive vehicles every 2/3 years, however, given that mountain bike brakes experience harsh use and are expected to perform at their best every run, it would be sensible to bleed the brakes more frequently than this. , , .
Another reason to change brake fluids regularly is that contaminants can accrue in the fluid, due to component wear (such as the seals and the master/slave cylinders), which can further accelerate deterioration of the seals and hoses etc. .
What Oil Do I Need?
SRAM uses and advocates DOT 5.1 fluid for the Guide/Code mountain bike brakes brakes, however, Shimano has opted to use mineral oil. There are a few advantages that DOT 5.1 brake fluid has over mineral oil which are as follows:
DOT 5.1 is less compressible than mineral oil. ;
Although DOT brake fluid absorbs water, the boiling point of DOT 5.1 brake fluid does not tend to deteriorate less than 180 degrees Celsius. (Mineral oil does not absorb water and so if enough water enters the hydraulic system, the boiling point of the water can become the limiting factor). ;
DOT brake fluid is manufactured to meet a specification created by the US DOT (US Department of Transport). The fluid is Glycol based (See Figure 3 below) and the standard has been widely adopted throughout the automotive industry. , .
The different DOT brake fluid standards identify the levels of refinement and the associated boiling points:
The 'dry' and 'wet' boiling point terms are defined as follows:
Dry - The boiling point of fresh brake fluid with no water absorption;
Wet - The boiling point after water absorption of 3.7% by weight.
Glycol ether compounds bond with water via a H bond. See Figure 5 below showing how water integrates with DOT brake fluid. A H Bond occurs when the positively charged Hydrogen atom is attracted to a negatively charged Oxygen atom from a different molecule. A water molecule can polarise enough (positively charged at one end and negatively charged at the other) to make an ionic bond of sorts with another molecule, this phenomenon is responsible for 'water tension'. , .
Step By Step Guide
In this guide we have used the SRAM Guide RSC mountain bike brakes.
What Tools & Materials Do I Need?
DOT 5.1 Brake Fluid;
SRAM Bleed Kit (NOTE: The newer generation callipers use a 'Bleeding Edge Adaptor' (more on this later.);
Torx Bit (T8 & T10);
Allen Key (2.5mm & 4mm);
Waste fluid container;
1) Remove the applicable wheel.
2) Remove brake pads, circlip and bolt along with the pads and place somewhere free of contaminants. Be careful not to contaminate the pads with any oils, as the pads will not grip the disc as well after contaminated, therefore, the performance of your brakes will be poor after reassembly.
3) Push slave cylinderback into the body of the brake calliper using your Rotae Tyre Lever Set pad separator as shown in Figure 6.
If you don't have a tyre lever to hand you can use a screw drive but be very careful as the slave cylinders are very fragile. We recommend that you use something soft made of plastic.
4) Once the slave cylinders of the brake callipers have been retracted into the body of the calliper install the bleed block as shown in Figure 7.
The purpose of this is to ensure the volume of the fluid in the system is correct. If you were to bleed the system with worn pads in place you risk contaminating the pads with oil, furthermore, when you come to replace the pads you might find you can't retract the pistons enough to fit the new pads in.
5) Prepare the syringes by screwing on the appropriate adaptors and filling with fluid.
The syringe to be connected to the reservoir on the lever assembly should be roughly 3/4 full, this is the fluid that will be pushed through the system to purge any air and old fluid. See Figure 9 below.
The syringe that is to be connected to the calliper should be filled with a small amount of fluid in order to minimise the risk of any air being sucked into the calliper. See Figure 8 Below.
Remove any air from the syringes by holding them upside down, placing a cloth over the end that will be connecting to the brake system and slowly squeeze until all the air floats to the top and is removed from the syringe. You shouldn't have to waste a lot of fluid in this process.
Once done then close off the the syringe with the clip on the hose as shown in Figure 10 and wipe the syringe clean.
NOTE: There are two different types of connector for the SRAM brakes, the threaded connection, and the 'Bleeding Edge Adaptor' shown in Figure 11. The 'Bleeding Edge' connector simply pushes into the calliper body and seals on the O-ring. It is then possible to open and shut the bleed port without having to disconnect your syringe, meaning there are less chances for spillages!
6) If your brake calliper uses the 'Bleeding Edge Adaptor' then you will need to loosen the bleed screw with an allen key (4mm) prior to connecting the 'Bleeding Edge Adaptor'.
If not then remove the bleed port screw.
7) Connect the syringe to the brake calliper as shown in Figure 12. This is where you will need to use the 'Bleeding Edge Adaptor' if applicable.