Eat or Bonk
Your body converts carbohydrates directly into glycogen, which is stored in your liver and muscles. Your glycogen reserves can sustain your blood sugar for about two hours of brisk riding or hills, and when you use this glycogen up without eating you will "bonk" and be unable to maintain your brisk pace. While riding less vigorously (that is, riding farther from your anaerobic threshold), training, and caffeine will extend this period by burning more fat in place of carbohydrates, the only solution to banking is to eat carbohydrate-rich foods as you ride.
Eat fruit or energy bars starting about an hour into your ride, with at least 250 calories per hour of brisk riding, preferably twice that to replace the energy you're consuming. Much more is needed for hard riding (close to your anaerobic threshold), or also at high altitude. It is important to eat regularly (such as by the clock) and relatively frequently to avoid brutal swings in your blood sugar.
If you do bank after a couple hours of hard riding, eat fruit, cookies, or energy bars for carbohydrates, and drink fruit juice, soft drinks (but slowly!), or energy drinks as soon as you can. Your body will process the sugars and carbohydrates into the glucose that your cells can use. Try to avoid sugars, instead favouring complex carbohydrates with a lower glycemic index, unless you need an immediate energy supply.
Balance Your Diet
Be sure to balance your diet, as you need carbs to metabolise fats. Similarly, soft drinks and juices containing only carbohydrates and sugars need to be supplemented with protein and fat. One theory is to get 40% of your calories from carbohydrates, 30% from protein, and 30% from fats, but generally you'll want to stick with easily-digested foods during a ride. This means no energy-intensive-to-digest fat, a bit of protein, some simple sugars, and tons of complex carbs.
A small dose of some fat can work wonders during longer rides, especially at normal mealtimes. With this in mind, it is important to carry diverse types of food to be able to respond to cravings of different sorts; for "sweet" carbohydrate-rich foods, or for more "substantial" fatty snacks.
It is fine to eat while riding if your stomach can handle it, but wash the food down with the water your body needs to process it to prevent the main problem of "bloating." Bloating happens when your stomach sucks water out of the rest of your body, and the solution is to drink water. Drinking is essential: aim for one large water bottle per hour of riding, or enough to make you urinate every two or three hours.
Time Your Eating
Eat often instead of in big lumps. Don't load up every six hours when you pass a restaurant, but regularly eat snacks instead. If your appetite disappears from fatigue or sleep deprivation, eat by wristwatch. 125-200 calories (2-5 cookies or 1-2 bananas) each half-hour is a good plan.
Don't eat anything difficult or large within 2-4 hours of a big ride. Your body's resources, such as blood flow, will be sent to the leg muscles instead of the stomach, and the protein and fats from that sirloin steak will just give you a backlog of difficult-to-digest filler when you're trying to convert get carbohydrates out of the bananas and power gels that you need to consume on a ride.
Further, as our article on Pre-Ride Performance Eating describes, eating something sugary within an hour of so of a ride will create an insulin reaction that depletes your body of blood sugar, just when it needs it most.
Time yourself to avoid the rush at checkpoint restaurants, and keep food around to use as a temporary meal replacement while you ride to the next, less crowded, checkpoint diner or to an eatery that isn't on the sheet.
Timing is an often overlooked aspect of eating. Your body is not prepared to deal with large amounts of food until about noon. While it is important to eat steadily and frequently, also try to time your larger meals to be about 20 minutes before a stop. Aside from the pause allowing digestion to proceed more normally, eating sends the signal for your bowels to move, and it is best to time your stops to coincide with urges to use the rest room.
To rebuild your muscle glycogen after a ride, try to eat at least 400 calories of carbohydrates soon after you stop. After several hours, eat about another 400 calories.
Load on Carbs in Advance
Marathon runners have been doing it since the dawn of time: eating lots of pasta and high-calorie, carbohydrate foods before a run. As we only have a reserve of 2000-3000 calories of glycogen (although your body also burns fat; less when riding hard), the more we can replenish this buffer the better, given the unattractive alternative of "bonking."
Eat a decent meal before your ride, with lots of pasta and carbohydrates, moderation in protein and low in fats, then give it enough time to settle and digest before you set out. Riding with lots of difficult-to-process food in your stomach can cause digestive distress when your blood flow and body resources are co-opted by your muscles.