(Fortune Magazine) -- With gas, grain, and dairy prices exploding, you'd think the biggest seller of corn flakes and Cocoa Puffs would be getting hit by rising food costs. But Wal-Mart has temporarily rolled back prices on hundreds of food items by as much as 30% this year. How? By pressuring vendors to take costs out of the supply chain.

"When our grocery suppliers bring price increases, we don't just accept them," says Pamela Kohn, Wal-Mart's general merchandise manager for perishables. To be sure, Wal-Mart (WMT, Fortune 500) isn't the only retailer working to cut fat from the food chain, but as the largest grocer - Wal-Mart's food and consumables revenue is nearly $100 billion - it has a disproportionate amount of leverage. Here's how the retailer is throwing its weight around.

Shrink the goods. Ever wonder why that cereal box is only two-thirds full? Foodmakers love big boxes because they serve as billboards on store shelves. Wal-Mart has been working to change that by promising suppliers that their shelf space won't shrink even if their boxes do. As a result, some of its vendors have reengineered their packaging. General Mills' (GIS, Fortune 500) Hamburger Helper is now made with denser pasta shapes, allowing the same amount of food to fit into a 20% smaller box at the same price. The change has saved 890,000 pounds of paper fiber and eliminated 500 trucks from the road, giving General Mills a cushion to absorb some of the rising costs.

Cut out the middleman. Wal-Mart typically buys its brand-name coffee from a supplier, which buys from a cooperative of growers, which works with a roaster - which means "there are a whole bunch of people muddled in the middle," says Wal-Mart spokeswoman Tara Raddohl. In April the chain began buying directly from a cooperative of Brazilian coffee farmers for its Sam's Choice brand, cutting three or four steps out of the supply chain.

Go locovore. Wal-Mart has been going green, but not entirely for the reasons you might think. By sourcing more produce locally - it now sells Wisconsin-grown yellow corn in 56 stores in or near Wisconsin - it is able to cut shipping costs. "We are looking at how to reduce the number of miles our suppliers' trucks travel," says Kohn. Marc Turner, whose Bushwick Potato Co. supplies Wal-Mart stores in the Northeast, says the cost of shipping one truck of spuds from his farm in Maine to local Wal-Mart stores costs less than $1,000, compared with several thousand dollars for a big rig from Idaho. Last year his shipments to Wal-Mart grew 13%.

In fact, it's the small suppliers that are feeling the pain from Wal-Mart's pushback the most. Bushwick has seen its costs rise 10% over the past year, but has passed only half that amount on to Wal-Mart and its other retailers. For consumers who are having a hard time paying $3.80 for a gallon of milk, however, without those measures that sticker shock would be a lot worse.